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"
22 class AMDGPUConvertToISAPass
: public MachineFunctionPass
{
28 void lowerFLT(MachineInstr
&MI
);
31 AMDGPUConvertToISAPass(TargetMachine
&tm
) :
32 MachineFunctionPass(ID
), TM(tm
) { }
34 virtual bool runOnMachineFunction(MachineFunction
&MF
);
37 } /* End anonymous namespace */
39 char AMDGPUConvertToISAPass::ID
= 0;
41 FunctionPass
*llvm::createAMDGPUConvertToISAPass(TargetMachine
&tm
) {
42 return new AMDGPUConvertToISAPass(tm
);
45 bool AMDGPUConvertToISAPass::runOnMachineFunction(MachineFunction
&MF
)
47 const AMDGPUInstrInfo
* TII
=
48 static_cast<const AMDGPUInstrInfo
*>(TM
.getInstrInfo());
50 for (MachineFunction::iterator BB
= MF
.begin(), BB_E
= MF
.end();
52 MachineBasicBlock
&MBB
= *BB
;
53 for (MachineBasicBlock::iterator I
= MBB
.begin(), Next
= llvm::next(I
);
54 I
!= MBB
.end(); I
= Next
, Next
= llvm::next(I
) ) {
55 MachineInstr
&MI
= *I
;
56 MachineInstr
* newInstr
= TII
->convertToISA(MI
, MF
, MBB
.findDebugLoc(I
));
60 MBB
.insert(I
, newInstr
);