-no-implicit-float means explicit fp operations are legal.
[oota-llvm.git] / lib / Target / X86 / X86CodeEmitter.cpp
index 828d1ad651a9c899cad96e4bd7eb61511a29ba1e..bbe063b4f821efb2b4b6ce8b150907c122e5c7e2 100644 (file)
@@ -516,10 +516,12 @@ void Emitter::emitInstruction(const MachineInstr &MI,
       assert(0 && "psuedo instructions should be removed before code emission");
       break;
     case TargetInstrInfo::INLINEASM: {
-      const char* Value = MI.getOperand(0).getSymbolName();
-      /* We allow inline assembler nodes with empty bodies - they can
-         implicitly define registers, which is ok for JIT. */
-      assert((Value[0] == 0) && "JIT does not support inline asm!\n");
+      // We allow inline assembler nodes with empty bodies - they can
+      // implicitly define registers, which is ok for JIT.
+      if (MI.getOperand(0).getSymbolName()[0]) {
+        assert(0 && "JIT does not support inline asm!\n");
+        abort();
+      }
       break;
     }
     case TargetInstrInfo::DBG_LABEL:
@@ -553,7 +555,7 @@ void Emitter::emitInstruction(const MachineInstr &MI,
       MCE.emitByte(BaseOpcode);
       emitConstant(0, X86InstrInfo::sizeOfImm(Desc));
       // Remember PIC base.
-      PICBaseOffset = MCE.getCurrentPCOffset();
+      PICBaseOffset = (intptr_t) MCE.getCurrentPCOffset();
       X86JITInfo *JTI = TM.getJITInfo();
       JTI->setPICBase(MCE.getCurrentPCValue());
       break;
@@ -587,7 +589,13 @@ void Emitter::emitInstruction(const MachineInstr &MI,
       } else if (MO.isSymbol()) {
         emitExternalSymbolAddress(MO.getSymbolName(), X86::reloc_pcrel_word);
       } else if (MO.isImm()) {
-        emitConstant(MO.getImm(), X86InstrInfo::sizeOfImm(Desc));
+        if (Opcode == X86::CALLpcrel32 || Opcode == X86::CALL64pcrel32) {
+          // Fix up immediate operand for pc relative calls.
+          intptr_t Imm = (intptr_t)MO.getImm();
+          Imm = Imm - MCE.getCurrentPCValue() - 4;
+          emitConstant(Imm, X86InstrInfo::sizeOfImm(Desc));
+        } else
+          emitConstant(MO.getImm(), X86InstrInfo::sizeOfImm(Desc));
       } else {
         assert(0 && "Unknown RawFrm operand!");
       }