aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-07-23 02:49:37 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-07-23 02:49:37 +0000
commita397a11c7c60e500baa36eea59a46a9aa2e5f35b (patch)
treee8c10a1d46e54d400499321f91b252b06ea572b1 /utils
parent71883edee29bbbbf3af2aca08de9e50e257252e7 (diff)
downloadexternal_llvm-a397a11c7c60e500baa36eea59a46a9aa2e5f35b.zip
external_llvm-a397a11c7c60e500baa36eea59a46a9aa2e5f35b.tar.gz
external_llvm-a397a11c7c60e500baa36eea59a46a9aa2e5f35b.tar.bz2
We always bounds check the bit set, there is no need to emit zero bytes at the end.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135841 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/RegisterInfoEmitter.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp
index 8ec45d41..f56dcd5 100644
--- a/utils/TableGen/RegisterInfoEmitter.cpp
+++ b/utils/TableGen/RegisterInfoEmitter.cpp
@@ -206,23 +206,20 @@ RegisterInfoEmitter::EmitRegMapping(raw_ostream &OS,
// Helper to emit a set of bits into a constant byte array.
class BitVectorEmitter {
BitVector Values;
- unsigned Len;
public:
- BitVectorEmitter(unsigned L) : Len(L%8 ? ((L/8)+1)*8 : L) {
- Values.resize(Len);
+ void add(unsigned v) {
+ if (v >= Values.size())
+ Values.resize(((v/8)+1)*8); // Round up to the next byte.
+ Values[v] = true;
}
- void add(unsigned v) { Values[v] = true; }
-
void print(raw_ostream &OS) {
- for (unsigned i = 0, e = Len / 8; i != e; ++i) {
+ for (unsigned i = 0, e = Values.size() / 8; i != e; ++i) {
unsigned char out = 0;
- for (unsigned ii = 0, ie = 8; ii != ie; ++ii)
- if (Values[i * 8 + ii])
- out |= 1 << ii;
- OS << "0x";
- OS.write_hex(out);
- OS << ", ";
+ for (unsigned j = 0; j != 8; ++j)
+ if (Values[i * 8 + j])
+ out |= 1 << j;
+ OS << format("0x%02x, ", out);
}
}
};
@@ -349,7 +346,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
OS << " // " << Name << " Bit set.\n"
<< " static const unsigned char " << Name
<< "Bits[] = {\n ";
- BitVectorEmitter BVE(Target.getRegBank().getRegisters().size()+1);
+ BitVectorEmitter BVE;
for (unsigned i = 0, e = Order.size(); i != e; ++i) {
Record *Reg = Order[i];
BVE.add(Target.getRegBank().getReg(Reg)->EnumValue);