CMake: Builds all targets.
[oota-llvm.git] / lib / Target / Alpha / AlphaCodeEmitter.cpp
index 6d68fa9678b09256b53460fcbb64c74b01cd2f53..b51440932f7964f21486ffae7efa970842ae6c35 100644 (file)
@@ -33,15 +33,16 @@ namespace {
 
     /// getMachineOpValue - evaluates the MachineOperand of a given MachineInstr
     ///
-    int getMachineOpValue(MachineInstr &MI, MachineOperand &MO);
+    unsigned getMachineOpValue(const MachineInstr &MI,
+                               const MachineOperand &MO);
 
   public:
     static char ID;
     explicit AlphaCodeEmitter(TargetMachine &tm, MachineCodeEmitter &mce)
-      : MachineFunctionPass((intptr_t)&ID), II(0), TM(tm), MCE(mce) {}
+      : MachineFunctionPass(&ID), II(0), TM(tm), MCE(mce) {}
     AlphaCodeEmitter(TargetMachine &tm, MachineCodeEmitter &mce,
                      const AlphaInstrInfo& ii)
-      : MachineFunctionPass((intptr_t)&ID), II(&ii), TM(tm), MCE(mce) {}
+      : MachineFunctionPass(&ID), II(&ii), TM(tm), MCE(mce) {}
 
     bool runOnMachineFunction(MachineFunction &MF);
 
@@ -55,7 +56,7 @@ namespace {
     /// CodeEmitterGenerator using TableGen, produces the binary encoding for
     /// machine instructions.
     ///
-    unsigned getBinaryCodeForInstr(MachineInstr &MI);
+    unsigned getBinaryCodeForInstr(const MachineInstr &MI);
 
   private:
     void emitBasicBlock(MachineBasicBlock &MBB);
@@ -87,7 +88,7 @@ void AlphaCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
   MCE.StartMachineBasicBlock(&MBB);
   for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
        I != E; ++I) {
-    MachineInstr &MI = *I;
+    const MachineInstr &MI = *I;
     switch(MI.getOpcode()) {
     default:
       MCE.emitWordLE(getBinaryCodeForInstr(*I));
@@ -95,9 +96,7 @@ void AlphaCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
     case Alpha::ALTENT:
     case Alpha::PCLABEL:
     case Alpha::MEMLABEL:
-    case Alpha::IDEF_I:
-    case Alpha::IDEF_F32:
-    case Alpha::IDEF_F64:
+    case TargetInstrInfo::IMPLICIT_DEF:
       break; //skip these
     }
   }
@@ -143,10 +142,11 @@ static unsigned getAlphaRegNumber(unsigned Reg) {
   }
 }
 
-int AlphaCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
+unsigned AlphaCodeEmitter::getMachineOpValue(const MachineInstr &MI,
+                                             const MachineOperand &MO) {
 
-  int rv = 0; // Return value; defaults to 0 for unhandled cases
-              // or things that get fixed up later by the JIT.
+  unsigned rv = 0; // Return value; defaults to 0 for unhandled cases
+                   // or things that get fixed up later by the JIT.
 
   if (MO.isRegister()) {
     rv = getAlphaRegNumber(MO.getReg());
@@ -196,19 +196,18 @@ int AlphaCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
     if (MO.isGlobalAddress())
       MCE.addRelocation(MachineRelocation::getGV(MCE.getCurrentPCOffset(),
                                                  Reloc, MO.getGlobal(), Offset,
-                                                 false, useGOT));
+                                                 isa<Function>(MO.getGlobal()),
+                                                 useGOT));
     else if (MO.isExternalSymbol())
       MCE.addRelocation(MachineRelocation::getExtSym(MCE.getCurrentPCOffset(),
                                                      Reloc, MO.getSymbolName(),
                                                      Offset, true));
     else
-    MCE.addRelocation(MachineRelocation::getConstPool(MCE.getCurrentPCOffset(),
-                                          Reloc, MO.getConstantPoolIndex(),
-                                          Offset));
+     MCE.addRelocation(MachineRelocation::getConstPool(MCE.getCurrentPCOffset(),
+                                          Reloc, MO.getIndex(), Offset));
   } else if (MO.isMachineBasicBlock()) {
     MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(),
-                                               Alpha::reloc_bsr,
-                                               MO.getMachineBasicBlock()));
+                                               Alpha::reloc_bsr, MO.getMBB()));
   }else {
     cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
     abort();