mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-29 14:40:39 +00:00
Use %rip-relative addressing on x86-64 whenever practical, as
it has a smaller encoding than absolute addressing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67002 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9a49d31b6f
commit
72bb0a64af
@ -471,14 +471,15 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
O << "@GOT";
|
||||
else
|
||||
O << "@GOTOFF";
|
||||
} else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel &&
|
||||
TM.getRelocationModel() != Reloc::Static) {
|
||||
if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
|
||||
O << "@GOTPCREL";
|
||||
} else if (Subtarget->isPICStyleRIPRel() && !NotRIPRel) {
|
||||
if (TM.getRelocationModel() != Reloc::Static) {
|
||||
if (Subtarget->GVRequiresExtraLoad(GV, TM, false))
|
||||
O << "@GOTPCREL";
|
||||
|
||||
if (needCloseParen) {
|
||||
needCloseParen = false;
|
||||
O << ')';
|
||||
if (needCloseParen) {
|
||||
needCloseParen = false;
|
||||
O << ')';
|
||||
}
|
||||
}
|
||||
|
||||
// Use rip when possible to reduce code size, except when
|
||||
@ -692,7 +693,7 @@ bool X86ATTAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
switch (ExtraCode[0]) {
|
||||
default: return true; // Unknown modifier.
|
||||
case 'c': // Don't print "$" before a global var name or constant.
|
||||
printOperand(MI, OpNo, "mem");
|
||||
printOperand(MI, OpNo, "mem", /*NotRIPRel=*/true);
|
||||
return false;
|
||||
case 'b': // Print QImode register
|
||||
case 'h': // Print QImode high register
|
||||
|
7
test/CodeGen/X86/rip-rel-address.ll
Normal file
7
test/CodeGen/X86/rip-rel-address.ll
Normal file
@ -0,0 +1,7 @@
|
||||
; RUN: llvm-as < %s | llc -march=x86-64 -relocation-model=static | grep {a(%rip)}
|
||||
|
||||
@a = internal global double 3.4
|
||||
define double @foo() nounwind {
|
||||
%a = load double* @a
|
||||
ret double %a
|
||||
}
|
Loading…
Reference in New Issue
Block a user