radeon/llvm: Remove AMDILBarrierDetect.cpp
authorTom Stellard <thomas.stellard@amd.com>
Wed, 25 Apr 2012 01:48:14 +0000 (21:48 -0400)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 25 Apr 2012 13:02:16 +0000 (09:02 -0400)
src/gallium/drivers/radeon/AMDGPUTargetMachine.cpp
src/gallium/drivers/radeon/AMDIL.h
src/gallium/drivers/radeon/AMDILBarrierDetect.cpp [deleted file]
src/gallium/drivers/radeon/AMDILTargetMachine.cpp
src/gallium/drivers/radeon/Makefile.sources

index 399bc139cdbf072aa7957b26aa6df5f7175e2363..1e24f18d29fcd6cab0d4d1aecb89734928eb1693 100644 (file)
@@ -123,7 +123,6 @@ bool AMDGPUPassConfig::addInstSelector() {
   if (ST.device()->getGeneration() == AMDILDeviceInfo::HD7XXX) {
     PM.add(createSIInitMachineFunctionInfoPass(*TM));
   }
-  PM.add(createAMDILBarrierDetect(*TM));
   PM.add(createAMDILInlinePass(*TM));
   PM.add(createAMDILPeepholeOpt(*TM));
   PM.add(createAMDILISelDag(getAMDGPUTargetMachine()));
index a03e1141a06545dd0e7953adb6be1b2013e57247..de5a1e91881b987dc6dcd6661ee4ceb131dd71a2 100644 (file)
@@ -92,8 +92,6 @@ class TargetMachine;
 /// Instruction selection passes.
 FunctionPass*
   createAMDILISelDag(AMDILTargetMachine &TM AMDIL_OPT_LEVEL_DECL);
-FunctionPass*
-  createAMDILBarrierDetect(TargetMachine &TM AMDIL_OPT_LEVEL_DECL);
 FunctionPass*
   createAMDILInlinePass(TargetMachine &TM AMDIL_OPT_LEVEL_DECL);
 FunctionPass*
diff --git a/src/gallium/drivers/radeon/AMDILBarrierDetect.cpp b/src/gallium/drivers/radeon/AMDILBarrierDetect.cpp
deleted file mode 100644 (file)
index 1bc9651..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-//===----- AMDILBarrierDetect.cpp - Barrier Detect pass -*- C++ -*- ------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//==-----------------------------------------------------------------------===//
-
-#define DEBUG_TYPE "BarrierDetect"
-#ifdef DEBUG
-#define DEBUGME (DebugFlag && isCurrentDebugType(DEBUG_TYPE))
-#else
-#define DEBUGME 0
-#endif
-#include "AMDILAlgorithms.tpp"
-#include "AMDILCompilerWarnings.h"
-#include "AMDILDevices.h"
-#include "AMDILMachineFunctionInfo.h"
-#include "AMDILSubtarget.h"
-#include "AMDILTargetMachine.h"
-#include "llvm/BasicBlock.h"
-#include "llvm/CodeGen/MachineFunctionAnalysis.h"
-#include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/CodeGen/Passes.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/Module.h"
-#include "llvm/Target/TargetMachine.h"
-
-using namespace llvm;
-
-// The barrier detect pass determines if a barrier has been duplicated in the
-// source program which can cause undefined behaviour if more than a single
-// wavefront is executed in a group. This is because LLVM does not have an
-// execution barrier and if this barrier function gets duplicated, undefined
-// behaviour can occur. In order to work around this, we detect the duplicated
-// barrier and then make the work-group execute in a single wavefront mode,
-// essentially making the barrier a no-op.
-
-namespace
-{
-  class LLVM_LIBRARY_VISIBILITY AMDILBarrierDetect : public FunctionPass
-  {
-    TargetMachine &TM;
-    static char ID;
-  public:
-    AMDILBarrierDetect(TargetMachine &TM AMDIL_OPT_LEVEL_DECL);
-    ~AMDILBarrierDetect();
-    const char *getPassName() const;
-    bool runOnFunction(Function &F);
-    bool doInitialization(Module &M);
-    bool doFinalization(Module &M);
-    void getAnalysisUsage(AnalysisUsage &AU) const;
-  private:
-    bool detectBarrier(BasicBlock::iterator *BBI);
-    bool detectMemFence(BasicBlock::iterator *BBI);
-    bool mChanged;
-    SmallVector<int64_t, DEFAULT_VEC_SLOTS> bVecMap;
-    const AMDILSubtarget *mStm;
-
-    // Constants used to define memory type.
-    static const unsigned int LOCAL_MEM_FENCE = 1<<0;
-    static const unsigned int GLOBAL_MEM_FENCE = 1<<1;
-    static const unsigned int REGION_MEM_FENCE = 1<<2;
-  };
-  char AMDILBarrierDetect::ID = 0;
-} // anonymouse namespace
-
-namespace llvm
-{
-  FunctionPass *
-  createAMDILBarrierDetect(TargetMachine &TM AMDIL_OPT_LEVEL_DECL)
-  {
-    return new AMDILBarrierDetect(TM  AMDIL_OPT_LEVEL_VAR);
-  }
-} // llvm namespace
-
-AMDILBarrierDetect::AMDILBarrierDetect(TargetMachine &TM
-                                       AMDIL_OPT_LEVEL_DECL)
-  :
-  FunctionPass(ID),
-  TM(TM)
-{
-}
-
-AMDILBarrierDetect::~AMDILBarrierDetect()
-{
-}
-
-bool AMDILBarrierDetect::detectBarrier(BasicBlock::iterator *BBI)
-{
-  SmallVector<int64_t, DEFAULT_VEC_SLOTS>::iterator bIter;
-  int64_t bID;
-  Instruction *inst = (*BBI);
-  CallInst *CI = dyn_cast<CallInst>(inst);
-
-  if (!CI || !CI->getNumOperands()) {
-    return false;
-  }
-  const Value *funcVal = CI->getOperand(CI->getNumOperands() - 1);
-  if (funcVal && strncmp(funcVal->getName().data(), "__amd_barrier", 13)) {
-    return false;
-  }
-
-  if (inst->getNumOperands() >= 3) {
-    const Value *V = inst->getOperand(0);
-    const ConstantInt *Cint = dyn_cast<ConstantInt>(V);
-    bID = Cint->getSExtValue();
-    bIter = std::find(bVecMap.begin(), bVecMap.end(), bID);
-    if (bIter == bVecMap.end()) {
-      bVecMap.push_back(bID);
-    } else {
-      if (mStm->device()->isSupported(AMDILDeviceInfo::BarrierDetect)) {
-        AMDILMachineFunctionInfo *MFI =
-          getAnalysis<MachineFunctionAnalysis>().getMF()
-          .getInfo<AMDILMachineFunctionInfo>();
-        MFI->addMetadata(";limitgroupsize");
-        MFI->addErrorMsg(amd::CompilerWarningMessage[BAD_BARRIER_OPT]);
-      }
-    }
-  }
-  if (mStm->device()->getGeneration() == AMDILDeviceInfo::HD4XXX) {
-    AMDILMachineFunctionInfo *MFI =
-      getAnalysis<MachineFunctionAnalysis>().getMF()
-          .getInfo<AMDILMachineFunctionInfo>();
-    MFI->addErrorMsg(amd::CompilerWarningMessage[LIMIT_BARRIER]);
-    MFI->addMetadata(";limitgroupsize");
-    MFI->setUsesLocal();
-  }
-  const Value *V = inst->getOperand(inst->getNumOperands()-2);
-  const ConstantInt *Cint = dyn_cast<ConstantInt>(V);
-  Function *iF = dyn_cast<Function>(inst->getOperand(inst->getNumOperands()-1));
-  Module *M = iF->getParent();
-  bID = Cint->getSExtValue();
-  if (bID > 0) {
-    const char *name = "barrier";
-    if (bID == GLOBAL_MEM_FENCE) {
-      name = "barrierGlobal";
-    } else if (bID == LOCAL_MEM_FENCE
-        && mStm->device()->usesHardware(AMDILDeviceInfo::LocalMem)) {
-      name = "barrierLocal";
-    } else if (bID == REGION_MEM_FENCE
-               && mStm->device()->usesHardware(AMDILDeviceInfo::RegionMem)) {
-      name = "barrierRegion";
-    }
-    Function *nF =
-      dyn_cast<Function>(M->getOrInsertFunction(name, iF->getFunctionType()));
-    inst->setOperand(inst->getNumOperands()-1, nF);
-    return false;
-  }
-
-  return false;
-}
-
-bool AMDILBarrierDetect::detectMemFence(BasicBlock::iterator *BBI)
-{
-  int64_t bID;
-  Instruction *inst = (*BBI);
-  CallInst *CI = dyn_cast<CallInst>(inst);
-
-  if (!CI || CI->getNumOperands() != 2) {
-    return false;
-  }
-
-  const Value *V = inst->getOperand(inst->getNumOperands()-2);
-  const ConstantInt *Cint = dyn_cast<ConstantInt>(V);
-  Function *iF = dyn_cast<Function>(inst->getOperand(inst->getNumOperands()-1));
-
-  const char *fence_local_name;
-  const char *fence_global_name;
-  const char *fence_region_name;
-  const char* fence_name = "mem_fence";
-  if (!iF) {
-    return false;
-  }
-
-  if (strncmp(iF->getName().data(), "mem_fence", 9) == 0) {
-    fence_local_name = "mem_fence_local";
-    fence_global_name = "mem_fence_global";
-    fence_region_name = "mem_fence_region";
-  } else if (strncmp(iF->getName().data(), "read_mem_fence", 14) == 0) {
-    fence_local_name = "read_mem_fence_local";
-    fence_global_name = "read_mem_fence_global";
-    fence_region_name = "read_mem_fence_region";
-  } else if (strncmp(iF->getName().data(), "write_mem_fence", 15) == 0) {
-    fence_local_name = "write_mem_fence_local";
-    fence_global_name = "write_mem_fence_global";
-    fence_region_name = "write_mem_fence_region";
-  } else {
-    return false;
-  }
-
-  Module *M = iF->getParent();
-  bID = Cint->getSExtValue();
-  if (bID > 0) {
-    const char *name = fence_name;
-    if (bID == GLOBAL_MEM_FENCE) {
-      name = fence_global_name;
-    } else if (bID == LOCAL_MEM_FENCE
-        && mStm->device()->usesHardware(AMDILDeviceInfo::LocalMem)) {
-      name = fence_local_name;
-    } else if (bID == REGION_MEM_FENCE
-               && mStm->device()->usesHardware(AMDILDeviceInfo::RegionMem)) {
-      name = fence_region_name;
-    }
-    Function *nF =
-      dyn_cast<Function>(M->getOrInsertFunction(name, iF->getFunctionType()));
-    inst->setOperand(inst->getNumOperands()-1, nF);
-    return false;
-  }
-
-  return false;
-
-}
-
-bool AMDILBarrierDetect::runOnFunction(Function &MF)
-{
-  mChanged = false;
-  bVecMap.clear();
-  mStm = &TM.getSubtarget<AMDILSubtarget>();
-  Function *F = &MF;
-  safeNestedForEach(F->begin(), F->end(), F->begin()->begin(),
-      std::bind1st(
-        std::mem_fun(
-          &AMDILBarrierDetect::detectBarrier), this));
-  safeNestedForEach(F->begin(), F->end(), F->begin()->begin(),
-      std::bind1st(
-        std::mem_fun(
-          &AMDILBarrierDetect::detectMemFence), this));
-  return mChanged;
-}
-
-const char* AMDILBarrierDetect::getPassName() const
-{
-  return "AMDIL Barrier Detect Pass";
-}
-
-bool AMDILBarrierDetect::doInitialization(Module &M)
-{
-  return false;
-}
-
-bool AMDILBarrierDetect::doFinalization(Module &M)
-{
-  return false;
-}
-
-void AMDILBarrierDetect::getAnalysisUsage(AnalysisUsage &AU) const
-{
-  AU.addRequired<MachineFunctionAnalysis>();
-  FunctionPass::getAnalysisUsage(AU);
-  AU.setPreservesAll();
-}
index ce71e9faa0fd102b54e555a66806f0679e32438d..7b60fd30ca7902035a3cac8dcdf4ace98411b1df 100644 (file)
@@ -157,7 +157,6 @@ bool AMDILPassConfig::addPreISel()
 
 bool AMDILPassConfig::addInstSelector()
 {
-  PM.add(createAMDILBarrierDetect(*TM));
   PM.add(createAMDILInlinePass(*TM));
   PM.add(createAMDILPeepholeOpt(*TM));
   PM.add(createAMDILISelDag(getAMDILTargetMachine()));
index 936cc09cad5d1d2354a38f3550a5f5bd6f6e7cca..d34e75a8b11605c663b09a26a2ebdfd6db29a365 100644 (file)
@@ -19,7 +19,6 @@ GENERATED_SOURCES := \
 
 CPP_SOURCES := \
        AMDIL7XXDevice.cpp              \
-       AMDILBarrierDetect.cpp          \
        AMDILCFGStructurizer.cpp        \
        AMDILDevice.cpp                 \
        AMDILDeviceInfo.cpp             \