5e8fe9ae2160f6df9c6354844af6f1abb5d2da0d
[oota-llvm.git] / lib / Target / AMDGPU / AMDGPUConvertToISA.cpp
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 // This pass lowers AMDIL machine instructions to the appropriate hardware
11 // instructions. 
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "AMDGPU.h"
16 #include "AMDGPUInstrInfo.h"
17 #include "llvm/CodeGen/MachineFunctionPass.h"
18
19 #include <stdio.h>
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 {
50   const AMDGPUInstrInfo * TII =
51                       static_cast<const AMDGPUInstrInfo*>(TM.getInstrInfo());
52
53   for (MachineFunction::iterator BB = MF.begin(), BB_E = MF.end();
54                                                   BB != BB_E; ++BB) {
55     MachineBasicBlock &MBB = *BB;
56     for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
57                                                       I != E; ++I) {
58       MachineInstr &MI = *I;
59       TII->convertToISA(MI, MF, MBB.findDebugLoc(I));
60     }
61   }
62   return false;
63 }