Commit c0d965fc by Jan Voung

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
parent 359c0360
...@@ -659,7 +659,7 @@ private: ...@@ -659,7 +659,7 @@ private:
void addGlobalInitializer(Ice::VariableDeclaration &Global, void addGlobalInitializer(Ice::VariableDeclaration &Global,
const Constant *Initializer) { const Constant *Initializer) {
const bool HasOffset = false; const bool HasOffset = false;
const Ice::VariableDeclaration::RelocOffsetType Offset = 0; const Ice::RelocOffsetT Offset = 0;
addGlobalInitializer(Global, Initializer, HasOffset, Offset); addGlobalInitializer(Global, Initializer, HasOffset, Offset);
} }
...@@ -669,12 +669,11 @@ private: ...@@ -669,12 +669,11 @@ private:
// relocation. // relocation.
void addGlobalInitializer(Ice::VariableDeclaration &Global, void addGlobalInitializer(Ice::VariableDeclaration &Global,
const Constant *Initializer, bool HasOffset, const Constant *Initializer, bool HasOffset,
Ice::VariableDeclaration::RelocOffsetType Offset); Ice::RelocOffsetT Offset);
// Converts the given constant C to the corresponding integer // Converts the given constant C to the corresponding integer
// literal it contains. // literal it contains.
Ice::VariableDeclaration::RelocOffsetType Ice::RelocOffsetT getIntegerLiteralConstant(const Value *C) {
getIntegerLiteralConstant(const Value *C) {
const auto CI = dyn_cast<ConstantInt>(C); const auto CI = dyn_cast<ConstantInt>(C);
if (CI && CI->getType()->isIntegerTy(32)) if (CI && CI->getType()->isIntegerTy(32))
return CI->getSExtValue(); return CI->getSExtValue();
...@@ -735,7 +734,7 @@ void LLVM2ICEGlobalsConverter::convertGlobalsToIce( ...@@ -735,7 +734,7 @@ void LLVM2ICEGlobalsConverter::convertGlobalsToIce(
void LLVM2ICEGlobalsConverter::addGlobalInitializer( void LLVM2ICEGlobalsConverter::addGlobalInitializer(
Ice::VariableDeclaration &Global, const Constant *Initializer, Ice::VariableDeclaration &Global, const Constant *Initializer,
bool HasOffset, Ice::VariableDeclaration::RelocOffsetType Offset) { bool HasOffset, Ice::RelocOffsetT Offset) {
(void)HasOffset; (void)HasOffset;
assert(HasOffset || Offset == 0); assert(HasOffset || Offset == 0);
......
...@@ -85,6 +85,7 @@ typedef uint32_t TimerIdT; ...@@ -85,6 +85,7 @@ typedef uint32_t TimerIdT;
// PNaCl is ILP32, so theoretically we should only need 32-bit offsets. // PNaCl is ILP32, so theoretically we should only need 32-bit offsets.
typedef int32_t RelocOffsetT; typedef int32_t RelocOffsetT;
enum { RelocAddrSize = 4 };
enum LivenessMode { enum LivenessMode {
// Basic version of live-range-end calculation. Marks the last uses // Basic version of live-range-end calculation. Marks the last uses
......
...@@ -216,22 +216,17 @@ public: ...@@ -216,22 +216,17 @@ public:
SizeT Size; 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. /// Defines the relocation value of another global declaration.
class RelocInitializer : public Initializer { class RelocInitializer : public Initializer {
RelocInitializer(const RelocInitializer &) = delete; RelocInitializer(const RelocInitializer &) = delete;
RelocInitializer &operator=(const RelocInitializer &) = delete; RelocInitializer &operator=(const RelocInitializer &) = delete;
public: public:
RelocInitializer(const GlobalDeclaration *Declaration, RelocInitializer(const GlobalDeclaration *Declaration, RelocOffsetT Offset)
RelocOffsetType Offset)
: Initializer(RelocInitializerKind), Declaration(Declaration), : Initializer(RelocInitializerKind), Declaration(Declaration),
Offset(Offset) {} Offset(Offset) {}
~RelocInitializer() override {} ~RelocInitializer() override {}
RelocOffsetType getOffset() const { return Offset; } RelocOffsetT getOffset() const { return Offset; }
const GlobalDeclaration *getDeclaration() const { return Declaration; } const GlobalDeclaration *getDeclaration() const { return Declaration; }
SizeT getNumBytes() const final { return RelocAddrSize; } SizeT getNumBytes() const final { return RelocAddrSize; }
void dump(GlobalContext *Ctx, Ostream &Stream) const final; void dump(GlobalContext *Ctx, Ostream &Stream) const final;
...@@ -244,7 +239,7 @@ public: ...@@ -244,7 +239,7 @@ public:
// The global declaration used in the relocation. // The global declaration used in the relocation.
const GlobalDeclaration *Declaration; const GlobalDeclaration *Declaration;
// The offset to add to the relocation. // The offset to add to the relocation.
const RelocOffsetType Offset; const RelocOffsetT Offset;
}; };
/// Models the list of initializers. /// Models the list of initializers.
......
...@@ -4702,7 +4702,7 @@ void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) { ...@@ -4702,7 +4702,7 @@ void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) {
llvm::cast<VariableDeclaration::RelocInitializer>(Init); llvm::cast<VariableDeclaration::RelocInitializer>(Init);
Str << "\t.long\t"; Str << "\t.long\t";
Str << Reloc->getDeclaration()->mangleName(Ctx); Str << Reloc->getDeclaration()->mangleName(Ctx);
if (VariableDeclaration::RelocOffsetType Offset = Reloc->getOffset()) { if (RelocOffsetT Offset = Reloc->getOffset()) {
if (Offset >= 0 || (Offset == INT32_MIN)) if (Offset >= 0 || (Offset == INT32_MIN))
Str << " + " << Offset; Str << " + " << Offset;
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment