Subzero: Use a common RelocOffsetType / RelocOffsetT. There is one in IceDefs.h and one in IceGlobalInits.h. Can we just use one? BUG=none (mini cleanup) R=kschimpf@google.com, stichnot@chromium.org Review URL: https://codereview.chromium.org/695563006
diff --git a/src/IceConverter.cpp b/src/IceConverter.cpp index bd6841c..3c46496 100644 --- a/src/IceConverter.cpp +++ b/src/IceConverter.cpp
@@ -659,7 +659,7 @@ void addGlobalInitializer(Ice::VariableDeclaration &Global, const Constant *Initializer) { const bool HasOffset = false; - const Ice::VariableDeclaration::RelocOffsetType Offset = 0; + const Ice::RelocOffsetT Offset = 0; addGlobalInitializer(Global, Initializer, HasOffset, Offset); } @@ -669,12 +669,11 @@ // relocation. void addGlobalInitializer(Ice::VariableDeclaration &Global, const Constant *Initializer, bool HasOffset, - Ice::VariableDeclaration::RelocOffsetType Offset); + Ice::RelocOffsetT Offset); // Converts the given constant C to the corresponding integer // literal it contains. - Ice::VariableDeclaration::RelocOffsetType - getIntegerLiteralConstant(const Value *C) { + Ice::RelocOffsetT getIntegerLiteralConstant(const Value *C) { const auto CI = dyn_cast<ConstantInt>(C); if (CI && CI->getType()->isIntegerTy(32)) return CI->getSExtValue(); @@ -735,7 +734,7 @@ void LLVM2ICEGlobalsConverter::addGlobalInitializer( Ice::VariableDeclaration &Global, const Constant *Initializer, - bool HasOffset, Ice::VariableDeclaration::RelocOffsetType Offset) { + bool HasOffset, Ice::RelocOffsetT Offset) { (void)HasOffset; assert(HasOffset || Offset == 0);
diff --git a/src/IceDefs.h b/src/IceDefs.h index 0beb3a3..2f0547e 100644 --- a/src/IceDefs.h +++ b/src/IceDefs.h
@@ -85,6 +85,7 @@ // PNaCl is ILP32, so theoretically we should only need 32-bit offsets. typedef int32_t RelocOffsetT; +enum { RelocAddrSize = 4 }; enum LivenessMode { // Basic version of live-range-end calculation. Marks the last uses
diff --git a/src/IceGlobalInits.h b/src/IceGlobalInits.h index b4c6299..d5974b4 100644 --- a/src/IceGlobalInits.h +++ b/src/IceGlobalInits.h
@@ -216,22 +216,17 @@ SizeT Size; }; - // Relocation address offsets must be 32 bit values. - typedef int32_t RelocOffsetType; - static const SizeT RelocAddrSize = 4; - /// Defines the relocation value of another global declaration. class RelocInitializer : public Initializer { RelocInitializer(const RelocInitializer &) = delete; RelocInitializer &operator=(const RelocInitializer &) = delete; public: - RelocInitializer(const GlobalDeclaration *Declaration, - RelocOffsetType Offset) + RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset) : Initializer(RelocInitializerKind), Declaration(Declaration), Offset(Offset) {} ~RelocInitializer() override {} - RelocOffsetType getOffset() const { return Offset; } + RelocOffsetT getOffset() const { return Offset; } const GlobalDeclaration *getDeclaration() const { return Declaration; } SizeT getNumBytes() const final { return RelocAddrSize; } void dump(GlobalContext *Ctx, Ostream &Stream) const final; @@ -244,7 +239,7 @@ // The global declaration used in the relocation. const GlobalDeclaration *Declaration; // The offset to add to the relocation. - const RelocOffsetType Offset; + const RelocOffsetT Offset; }; /// Models the list of initializers.
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp index 999556e..dc9a0e5 100644 --- a/src/IceTargetLoweringX8632.cpp +++ b/src/IceTargetLoweringX8632.cpp
@@ -4702,7 +4702,7 @@ llvm::cast<VariableDeclaration::RelocInitializer>(Init); Str << "\t.long\t"; Str << Reloc->getDeclaration()->mangleName(Ctx); - if (VariableDeclaration::RelocOffsetType Offset = Reloc->getOffset()) { + if (RelocOffsetT Offset = Reloc->getOffset()) { if (Offset >= 0 || (Offset == INT32_MIN)) Str << " + " << Offset; else