add a note
[oota-llvm.git] / lib / Target / Alpha / AlphaCodeEmitter.cpp
index cea0fe8982cdd3302bd9d21f11278895fa99a53f..f5d517fadd49d634280ca828329b39184c8b40b9 100644 (file)
@@ -23,6 +23,7 @@
 #include "llvm/Function.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/ADT/Statistic.h"
+#include <iostream>
 using namespace llvm;
 
 namespace {
@@ -89,9 +90,11 @@ bool AlphaCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
   for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) {
     unsigned* Location = (unsigned*)BasicBlockAddrs[BBRefs[i].first];
     unsigned* Ref = (unsigned*)BBRefs[i].second;
-    intptr_t BranchTargetDisp = (((unsigned char*)Location  - (unsigned char*)Ref) >> 2) - 1;
+    intptr_t BranchTargetDisp = 
+      (((unsigned char*)Location  - (unsigned char*)Ref) >> 2) - 1;
     DEBUG(std::cerr << "Fixup @ " << (void*)Ref << " to " << (void*)Location
-          << " Disp " << BranchTargetDisp << " using " <<  (BranchTargetDisp & ((1 << 22)-1)) << "\n");
+          << " Disp " << BranchTargetDisp 
+          << " using " <<  (BranchTargetDisp & ((1 << 22)-1)) << "\n");
     *Ref |= (BranchTargetDisp & ((1 << 21)-1));
   }
   BBRefs.clear();
@@ -115,6 +118,9 @@ 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:
       break; //skip these
     }
   }
@@ -178,7 +184,11 @@ int AlphaCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
          MO.getGlobal()->isExternal()) );
     unsigned Reloc = 0;
     int Offset = 0;
+    bool useGOT = false;
     switch (MI.getOpcode()) {
+    case Alpha::BSR:
+      Reloc = Alpha::reloc_bsr;
+      break;
     case Alpha::LDLr:
     case Alpha::LDQr:
     case Alpha::LDBUr:
@@ -186,6 +196,12 @@ int AlphaCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
     case Alpha::LDSr:
     case Alpha::LDTr:
     case Alpha::LDAr:
+    case Alpha::STQr:
+    case Alpha::STLr:
+    case Alpha::STWr:
+    case Alpha::STBr:
+    case Alpha::STSr:
+    case Alpha::STTr:
       Reloc = Alpha::reloc_gprellow;
       break;
     case Alpha::LDAHr:
@@ -193,6 +209,7 @@ int AlphaCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
       break;
     case Alpha::LDQl:
       Reloc = Alpha::reloc_literal;
+      useGOT = true;
       break;
     case Alpha::LDAg:
     case Alpha::LDAHg:
@@ -206,7 +223,7 @@ int AlphaCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) {
     if (MO.isGlobalAddress())
       MCE.addRelocation(MachineRelocation((unsigned)MCE.getCurrentPCOffset(),
                                           Reloc, MO.getGlobal(), Offset,
-                                          true, true));
+                                          false, useGOT));
     else if (MO.isExternalSymbol())
       MCE.addRelocation(MachineRelocation((unsigned)MCE.getCurrentPCOffset(),
                                           Reloc, MO.getSymbolName(), Offset,