Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: src/IceInstX8664.cpp

Issue 1616103002: Subzero. X8664. Enables RIP-based addressing mode. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceFixups.cpp ('k') | src/IceTargetLoweringX8664.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceInstX8664.cpp
diff --git a/src/IceInstX8664.cpp b/src/IceInstX8664.cpp
index a7236a3f67cd6f9de5992f8692927db97e7b81e3..7bac57ebe1e6f6f14c711317160627ebe45d4819 100644
--- a/src/IceInstX8664.cpp
+++ b/src/IceInstX8664.cpp
@@ -136,7 +136,17 @@ void TargetX8664Traits::X86OperandMem::emit(const Cfg *Func) const {
// rematerializable base/index and Disp.
assert(Disp == 0);
const bool UseNonsfi = Func->getContext()->getFlags().getUseNonsfi();
- CR->emitWithoutPrefix(Func->getTarget(), UseNonsfi ? "@GOTOFF" : "");
+ CR->emitWithoutPrefix(Target, UseNonsfi ? "@GOTOFF" : "");
+ assert(!UseNonsfi);
+ if (Base == nullptr && Index == nullptr) {
+ if (CR->getName() != "") { // rip-relative addressing.
+ if (NeedSandboxing) {
+ Str << "(%rip)";
+ } else {
+ Str << "(%eip)";
+ }
+ }
+ }
} else {
llvm_unreachable("Invalid offset type for x86 mem operand");
}
@@ -256,10 +266,16 @@ TargetX8664Traits::Address TargetX8664Traits::X86OperandMem::toAsmAddress(
if (getOffset() != nullptr) {
if (const auto *CI = llvm::dyn_cast<ConstantInteger32>(getOffset())) {
Disp += static_cast<int32_t>(CI->getValue());
- } else if (const auto CR =
+ } else if (const auto *CR =
llvm::dyn_cast<ConstantRelocatable>(getOffset())) {
- Disp = CR->getOffset();
- Fixup = Asm->createFixup(FK_Abs, CR);
+ RelocOffsetT DispAdjustment = 0;
+ if (CR->getName() != "") {
+ const auto FixupKind =
+ (getBase() != nullptr || getIndex() != nullptr) ? FK_Abs : FK_PcRel;
+ DispAdjustment = FixupKind == FK_PcRel ? 4 : 0;
+ Fixup = Asm->createFixup(FixupKind, CR);
+ }
+ Disp = CR->getOffset() - DispAdjustment;
} else {
llvm_unreachable("Unexpected offset type");
}
@@ -290,7 +306,15 @@ TargetX8664Traits::Address TargetX8664Traits::X86OperandMem::toAsmAddress(
Fixup);
}
- return X8664::Traits::Address(Disp, Fixup);
+ if (Fixup == nullptr) {
+ // Absolute addresses are not allowed in Nexes -- they must be rebased
+ // w.r.t. %r15.
+ // Exception: LEAs are fine because they do not touch memory.
+ assert(!Target->needSandboxing() || IsLeaAddr);
+ return X8664::Traits::Address::Absolute(Disp);
+ }
+
+ return X8664::Traits::Address::RipRelative(Disp, Fixup);
}
TargetX8664Traits::Address
« no previous file with comments | « src/IceFixups.cpp ('k') | src/IceTargetLoweringX8664.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698