llvm.org GIT mirror llvm / 40c791e
[TableGen] Merge single prefix bit in RecordVal into PointerIntPair with Name to reduce memory usage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239021 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
2 changed file(s) with 10 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
11121112 //===----------------------------------------------------------------------===//
11131113
11141114 class RecordVal {
1115 Init *Name;
1115 PointerIntPair NameAndPrefix;
11161116 RecTy *Ty;
1117 unsigned Prefix;
11181117 Init *Value;
11191118
11201119 public:
1121 RecordVal(Init *N, RecTy *T, unsigned P);
1122 RecordVal(const std::string &N, RecTy *T, unsigned P);
1120 RecordVal(Init *N, RecTy *T, bool P);
1121 RecordVal(const std::string &N, RecTy *T, bool P);
11231122
11241123 const std::string &getName() const;
1125 const Init *getNameInit() const { return Name; }
1124 const Init *getNameInit() const { return NameAndPrefix.getPointer(); }
11261125 std::string getNameInitAsString() const {
11271126 return getNameInit()->getAsUnquotedString();
11281127 }
11291128
1130 unsigned getPrefix() const { return Prefix; }
1129 bool getPrefix() const { return NameAndPrefix.getInt(); }
11311130 RecTy *getType() const { return Ty; }
11321131 Init *getValue() const { return Value; }
11331132
15311531 // Other implementations
15321532 //===----------------------------------------------------------------------===//
15331533
1534 RecordVal::RecordVal(Init *N, RecTy *T, unsigned P)
1535 : Name(N), Ty(T), Prefix(P) {
1534 RecordVal::RecordVal(Init *N, RecTy *T, bool P)
1535 : NameAndPrefix(N, P), Ty(T) {
15361536 Value = UnsetInit::get()->convertInitializerTo(Ty);
15371537 assert(Value && "Cannot create unset value for current type!");
15381538 }
15391539
1540 RecordVal::RecordVal(const std::string &N, RecTy *T, unsigned P)
1541 : Name(StringInit::get(N)), Ty(T), Prefix(P) {
1540 RecordVal::RecordVal(const std::string &N, RecTy *T, bool P)
1541 : NameAndPrefix(StringInit::get(N), P), Ty(T) {
15421542 Value = UnsetInit::get()->convertInitializerTo(Ty);
15431543 assert(Value && "Cannot create unset value for current type!");
15441544 }
15451545
15461546 const std::string &RecordVal::getName() const {
1547 return cast(Name)->getValue();
1547 return cast(getNameInit())->getValue();
15481548 }
15491549
15501550 void RecordVal::dump() const { errs() << *this; }