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:
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 @@ private:
// 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::convertGlobalsToIce(
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);
......
......@@ -85,6 +85,7 @@ typedef uint32_t TimerIdT;
// 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
......
......@@ -216,22 +216,17 @@ public:
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 @@ public:
// 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.
......
......@@ -4702,7 +4702,7 @@ void TargetGlobalInitX8632::lower(const VariableDeclaration &Var) {
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
......
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