1 //===-- AMDGPUConvertToISA.cpp - Lower AMDIL to HW ISA --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This pass lowers AMDIL machine instructions to the appropriate hardware
13 //===----------------------------------------------------------------------===//
16 #include "AMDGPUInstrInfo.h"
17 #include "llvm/CodeGen/MachineFunctionPass.h"
23 class AMDGPUConvertToISAPass
: public MachineFunctionPass
{
30 AMDGPUConvertToISAPass(TargetMachine
&tm
) :
31 MachineFunctionPass(ID
), TM(tm
) { }
33 virtual bool runOnMachineFunction(MachineFunction
&MF
);
35 virtual const char *getPassName() const {return "AMDGPU Convert to ISA";}
39 } // End anonymous namespace
41 char AMDGPUConvertToISAPass::ID
= 0;
43 FunctionPass
*llvm::createAMDGPUConvertToISAPass(TargetMachine
&tm
) {
44 return new AMDGPUConvertToISAPass(tm
);
47 bool AMDGPUConvertToISAPass::runOnMachineFunction(MachineFunction
&MF
)
49 const AMDGPUInstrInfo
* TII
=
50 static_cast<const AMDGPUInstrInfo
*>(TM
.getInstrInfo());
52 for (MachineFunction::iterator BB
= MF
.begin(), BB_E
= MF
.end();
54 MachineBasicBlock
&MBB
= *BB
;
55 for (MachineBasicBlock::iterator I
= MBB
.begin(), Next
= llvm::next(I
);
56 I
!= MBB
.end(); I
= Next
, Next
= llvm::next(I
) ) {
57 MachineInstr
&MI
= *I
;
58 MachineInstr
* newInstr
= TII
->convertToISA(MI
, MF
, MBB
.findDebugLoc(I
));
62 MBB
.insert(I
, newInstr
);