Home | History | Annotate | Download | only in R600
      1 //===-- AMDGPUConvertToISA.cpp - Lower AMDIL to HW ISA --------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 /// \file
     11 /// \brief This pass lowers AMDIL machine instructions to the appropriate
     12 /// hardware instructions.
     13 //
     14 //===----------------------------------------------------------------------===//
     15 
     16 #include "AMDGPU.h"
     17 #include "AMDGPUInstrInfo.h"
     18 #include "llvm/CodeGen/MachineFunctionPass.h"
     19 
     20 using namespace llvm;
     21 
     22 namespace {
     23 
     24 class AMDGPUConvertToISAPass : public MachineFunctionPass {
     25 
     26 private:
     27   static char ID;
     28   TargetMachine &TM;
     29 
     30 public:
     31   AMDGPUConvertToISAPass(TargetMachine &tm) :
     32     MachineFunctionPass(ID), TM(tm) { }
     33 
     34   virtual bool runOnMachineFunction(MachineFunction &MF);
     35 
     36   virtual const char *getPassName() const {return "AMDGPU Convert to ISA";}
     37 
     38 };
     39 
     40 } // End anonymous namespace
     41 
     42 char AMDGPUConvertToISAPass::ID = 0;
     43 
     44 FunctionPass *llvm::createAMDGPUConvertToISAPass(TargetMachine &tm) {
     45   return new AMDGPUConvertToISAPass(tm);
     46 }
     47 
     48 bool AMDGPUConvertToISAPass::runOnMachineFunction(MachineFunction &MF) {
     49   const AMDGPUInstrInfo * TII =
     50                       static_cast<const AMDGPUInstrInfo*>(TM.getInstrInfo());
     51 
     52   for (MachineFunction::iterator BB = MF.begin(), BB_E = MF.end();
     53                                                   BB != BB_E; ++BB) {
     54     MachineBasicBlock &MBB = *BB;
     55     for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
     56                                                       I != E; ++I) {
     57       MachineInstr &MI = *I;
     58       TII->convertToISA(MI, MF, MBB.findDebugLoc(I));
     59     }
     60   }
     61   return false;
     62 }
     63