diff options
Diffstat (limited to 'lib/Target/X86/X86FastISel.cpp')
-rw-r--r-- | lib/Target/X86/X86FastISel.cpp | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index 54704d84a9..23450f761c 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -580,6 +580,20 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) { // If all else fails, try to materialize the value in a register. if (!AM.GV || !Subtarget->isPICStyleRIPRel()) { + // @LOCALMOD-START + if (Subtarget->isTargetNaCl()) { + // We can materialize into a memory address only if + // no registers have been defined (and hence, we + // aren't modifying an existing memory reference). + if ((AM.Base.Reg == 0) && (AM.IndexReg == 0)) { + // Put into index register so that the NaCl rewrite pass will + // convert this to a 64-bit address. + AM.IndexReg = getRegForValue(V); + return AM.IndexReg != 0; + } + return false; + } + // @LOCALMOD-END if (AM.Base.Reg == 0) { AM.Base.Reg = getRegForValue(V); return AM.Base.Reg != 0; @@ -1818,10 +1832,21 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) { if (CalleeOp) { // Register-indirect call. unsigned CallOpc; - if (Subtarget->is64Bit()) - CallOpc = X86::CALL64r; - else - CallOpc = X86::CALL32r; + // @LOCALMOD-BEGIN + if (Subtarget->is64Bit()) { + if (Subtarget->isTargetNaCl()) { + CallOpc = X86::NACL_CG_CALL64r; + } else { + CallOpc = X86::CALL64r; + } + } else { + if (Subtarget->isTargetNaCl()) { + CallOpc = X86::NACL_CG_CALL32r; + } else { + CallOpc = X86::CALL32r; + } + } + // @LOCALMOD-END MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(CallOpc)) .addReg(CalleeOp); @@ -1829,10 +1854,21 @@ bool X86FastISel::DoSelectCall(const Instruction *I, const char *MemIntName) { // Direct call. assert(GV && "Not a direct call"); unsigned CallOpc; - if (Subtarget->is64Bit()) - CallOpc = X86::CALL64pcrel32; - else - CallOpc = X86::CALLpcrel32; + // @LOCALMOD-BEGIN + if (Subtarget->is64Bit()) { + if (Subtarget->isTargetNaCl()) { + CallOpc = X86::NACL_CG_CALL64pcrel32; + } else { + CallOpc = X86::CALL64pcrel32; + } + } else { + if (Subtarget->isTargetNaCl()) { + CallOpc = X86::NACL_CG_CALLpcrel32; + } else { + CallOpc = X86::CALLpcrel32; + } + } + // @LOCALMOD-END // See if we need any target-specific flags on the GV operand. unsigned char OpFlags = 0; |