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

Unified Diff: src/IceTargetLoweringX86Base.h

Issue 1605103002: Subzero. X86. Refactors Address Mode formation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: make format 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/IceTargetLoweringX8664.cpp ('k') | src/IceTargetLoweringX86BaseImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTargetLoweringX86Base.h
diff --git a/src/IceTargetLoweringX86Base.h b/src/IceTargetLoweringX86Base.h
index 2a4a728ccd3782f638610fa42f5d5b02a0fce694..d50d7212a2ee82a272e650129ce894cb3d0e24dd 100644
--- a/src/IceTargetLoweringX86Base.h
+++ b/src/IceTargetLoweringX86Base.h
@@ -194,7 +194,17 @@ protected:
void postLower() override;
+ /// Initializes the RebasePtr member variable -- if so required by
+ /// SandboxingType for the concrete Target.
+ void initRebasePtr() {
+ assert(SandboxingType != ST_None);
+ dispatchToConcrete(&Traits::ConcreteTarget::initRebasePtr);
+ }
+
+ /// Emit code that initializes the value of the RebasePtr near the start of
+ /// the function -- if so required by SandboxingType for the concrete type.
void initSandbox() {
+ assert(SandboxingType != ST_None);
dispatchToConcrete(&Traits::ConcreteTarget::initSandbox);
}
@@ -225,6 +235,25 @@ protected:
Type ReturnType);
uint32_t getCallStackArgumentsSizeBytes(const InstCall *Instr) override;
void genTargetHelperCallFor(Inst *Instr) override;
+
+ /// OptAddr wraps all the possible operands that an x86 address might have.
+ struct OptAddr {
+ Variable *Base = nullptr;
+ Variable *Index = nullptr;
+ uint16_t Shift = 0;
+ int32_t Offset = 0;
+ ConstantRelocatable *Relocatable = nullptr;
+ };
+ /// Legalizes Addr w.r.t. SandboxingType. The exact type of legalization
+ /// varies for different <Target, SandboxingType> tuples.
+ bool legalizeOptAddrForSandbox(OptAddr *Addr) {
+ return dispatchToConcrete(
+ &Traits::ConcreteTarget::legalizeOptAddrForSandbox, std::move(Addr));
+ }
+ // Builds information for a canonical address expresion:
+ // <Relocatable + Offset>(Base, Index, Shift)
+ X86OperandMem *computeAddressOpt(const Inst *Instr, Type MemType,
+ Operand *Addr);
void doAddressOptLoad() override;
void doAddressOptStore() override;
void doMockBoundsCheck(Operand *Opnd) override;
@@ -318,7 +347,7 @@ protected:
Legal_Imm = 1 << 1,
Legal_Mem = 1 << 2, // includes [eax+4*ecx] as well as [esp+12]
Legal_Rematerializable = 1 << 3,
- Legal_AddrAbs = 1 << 4, // ConstantRelocatable doesn't have to add GotVar
+ Legal_AddrAbs = 1 << 4, // ConstantRelocatable doesn't have to add RebasePtr
Legal_Default = ~(Legal_Rematerializable | Legal_AddrAbs)
// TODO(stichnot): Figure out whether this default works for x86-64.
};
@@ -406,11 +435,9 @@ protected:
template <typename... T>
AutoMemorySandboxer(typename Traits::TargetLowering *Target, T... Args)
- : Target(Target),
- MemOperand(
- (!Traits::Is64Bit || !Target->Ctx->getFlags().getUseSandboxing())
- ? nullptr
- : findMemoryReference(Args...)) {
+ : Target(Target), MemOperand(Target->SandboxingType == ST_None
+ ? nullptr
+ : findMemoryReference(Args...)) {
if (MemOperand != nullptr) {
Bundler = makeUnique<AutoBundle>(Target, BundleLockOpt);
*MemOperand = Target->_sandbox_mem_reference(*MemOperand);
@@ -928,9 +955,9 @@ protected:
RegisterAliases;
llvm::SmallBitVector RegsUsed;
std::array<VarList, IceType_NUM> PhysicalRegisters;
- // GotVar is a Variable that holds the GlobalOffsetTable address for Non-SFI
- // mode.
- Variable *GotVar = nullptr;
+ // RebasePtr is a Variable that holds the Rebasing pointer (if any) for the
+ // current sandboxing type.
+ Variable *RebasePtr = nullptr;
/// Randomize a given immediate operand
Operand *randomizeOrPoolImmediate(Constant *Immediate,
@@ -998,10 +1025,6 @@ private:
/// Optimizations for idiom recognition.
bool lowerOptimizeFcmpSelect(const InstFcmp *Fcmp, const InstSelect *Select);
- /// Emit code that initializes the value of the GotVar near the start of the
- /// function. (This code is emitted only in Non-SFI mode.)
- void initGotVarIfNeeded();
-
/// Complains loudly if invoked because the cpu can handle 64-bit types
/// natively.
template <typename T = Traits>
« no previous file with comments | « src/IceTargetLoweringX8664.cpp ('k') | src/IceTargetLoweringX86BaseImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698