aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/TargetAsmInfo.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-08-16 12:57:46 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-08-16 12:57:46 +0000
commitffe31d7bf1e070650b0ff9ebfac815ea172a82bb (patch)
tree2d393175d6a72aa68e404e7169ab57b41fc9d96f /lib/Target/TargetAsmInfo.cpp
parentd0c1e29aecdaaa67ffabbaf2dd255809e6df4978 (diff)
Move SLEB/ULEB size calculation routines from AsmPrinter to TargetAsmInfo. This makes JIT asmprinter-free.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54843 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetAsmInfo.cpp')
-rw-r--r--lib/Target/TargetAsmInfo.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index 1ef2182033..cc0745f680 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -389,3 +389,26 @@ TargetAsmInfo::getSectionFlags(unsigned Flags) const {
return I->second;
}
+
+unsigned TargetAsmInfo::getULEB128Size(unsigned Value) {
+ unsigned Size = 0;
+ do {
+ Value >>= 7;
+ Size += sizeof(int8_t);
+ } while (Value);
+ return Size;
+}
+
+unsigned TargetAsmInfo::getSLEB128Size(int Value) {
+ unsigned Size = 0;
+ int Sign = Value >> (8 * sizeof(Value) - 1);
+ bool IsMore;
+
+ do {
+ unsigned Byte = Value & 0x7f;
+ Value >>= 7;
+ IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
+ Size += sizeof(int8_t);
+ } while (IsMore);
+ return Size;
+}