forked from OSchip/llvm-project
Make clever use of padding to shrink IntegerLiterals.
Inheritance allows us to use padding across classes. 40 -> 32 bytes on x86_64. llvm-svn: 151499
This commit is contained in:
parent
74f011db76
commit
441607ddcb
|
@ -1085,11 +1085,11 @@ public:
|
||||||
/// the APFloat/APInt values will never get freed. APNumericStorage uses
|
/// the APFloat/APInt values will never get freed. APNumericStorage uses
|
||||||
/// ASTContext's allocator for memory allocation.
|
/// ASTContext's allocator for memory allocation.
|
||||||
class APNumericStorage {
|
class APNumericStorage {
|
||||||
unsigned BitWidth;
|
|
||||||
union {
|
union {
|
||||||
uint64_t VAL; ///< Used to store the <= 64 bits integer value.
|
uint64_t VAL; ///< Used to store the <= 64 bits integer value.
|
||||||
uint64_t *pVal; ///< Used to store the >64 bits integer value.
|
uint64_t *pVal; ///< Used to store the >64 bits integer value.
|
||||||
};
|
};
|
||||||
|
unsigned BitWidth;
|
||||||
|
|
||||||
bool hasAllocation() const { return llvm::APInt::getNumWords(BitWidth) > 1; }
|
bool hasAllocation() const { return llvm::APInt::getNumWords(BitWidth) > 1; }
|
||||||
|
|
||||||
|
@ -1097,7 +1097,7 @@ class APNumericStorage {
|
||||||
APNumericStorage& operator=(const APNumericStorage&); // do not implement
|
APNumericStorage& operator=(const APNumericStorage&); // do not implement
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
APNumericStorage() : BitWidth(0), VAL(0) { }
|
APNumericStorage() : VAL(0), BitWidth(0) { }
|
||||||
|
|
||||||
llvm::APInt getIntValue() const {
|
llvm::APInt getIntValue() const {
|
||||||
unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
|
unsigned NumWords = llvm::APInt::getNumWords(BitWidth);
|
||||||
|
@ -1109,7 +1109,7 @@ protected:
|
||||||
void setIntValue(ASTContext &C, const llvm::APInt &Val);
|
void setIntValue(ASTContext &C, const llvm::APInt &Val);
|
||||||
};
|
};
|
||||||
|
|
||||||
class APIntStorage : public APNumericStorage {
|
class APIntStorage : private APNumericStorage {
|
||||||
public:
|
public:
|
||||||
llvm::APInt getValue() const { return getIntValue(); }
|
llvm::APInt getValue() const { return getIntValue(); }
|
||||||
void setValue(ASTContext &C, const llvm::APInt &Val) { setIntValue(C, Val); }
|
void setValue(ASTContext &C, const llvm::APInt &Val) { setIntValue(C, Val); }
|
||||||
|
@ -1125,8 +1125,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IntegerLiteral : public Expr {
|
class IntegerLiteral : public Expr, public APIntStorage {
|
||||||
APIntStorage Num;
|
|
||||||
SourceLocation Loc;
|
SourceLocation Loc;
|
||||||
|
|
||||||
/// \brief Construct an empty integer literal.
|
/// \brief Construct an empty integer literal.
|
||||||
|
@ -1156,13 +1155,11 @@ public:
|
||||||
/// \brief Returns a new empty integer literal.
|
/// \brief Returns a new empty integer literal.
|
||||||
static IntegerLiteral *Create(ASTContext &C, EmptyShell Empty);
|
static IntegerLiteral *Create(ASTContext &C, EmptyShell Empty);
|
||||||
|
|
||||||
llvm::APInt getValue() const { return Num.getValue(); }
|
|
||||||
SourceRange getSourceRange() const { return SourceRange(Loc); }
|
SourceRange getSourceRange() const { return SourceRange(Loc); }
|
||||||
|
|
||||||
/// \brief Retrieve the location of the literal.
|
/// \brief Retrieve the location of the literal.
|
||||||
SourceLocation getLocation() const { return Loc; }
|
SourceLocation getLocation() const { return Loc; }
|
||||||
|
|
||||||
void setValue(ASTContext &C, const llvm::APInt &Val) { Num.setValue(C, Val); }
|
|
||||||
void setLocation(SourceLocation Location) { Loc = Location; }
|
void setLocation(SourceLocation Location) { Loc = Location; }
|
||||||
|
|
||||||
static bool classof(const Stmt *T) {
|
static bool classof(const Stmt *T) {
|
||||||
|
|
Loading…
Reference in New Issue