summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-04-19 01:17:35 +0000
committerChris Lattner <sabre@nondot.org>2005-04-19 01:17:35 +0000
commit3ff0e11294318e2e8ef7169303f7cf1ee73b0bbd (patch)
treeba20ed210dd8b9d7fa657a620ab4b25ec1d0b672 /llvm/utils
parent101fc501d00b38277e2e259eb1ab2a0543cc3f6d (diff)
downloadbcm5719-llvm-3ff0e11294318e2e8ef7169303f7cf1ee73b0bbd.tar.gz
bcm5719-llvm-3ff0e11294318e2e8ef7169303f7cf1ee73b0bbd.zip
implementing shifting of literal integers
llvm-svn: 21336
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/Record.cpp14
-rw-r--r--llvm/utils/TableGen/Record.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/Record.cpp b/llvm/utils/TableGen/Record.cpp
index 8c8e7b97f7b..d2422ff74b3 100644
--- a/llvm/utils/TableGen/Record.cpp
+++ b/llvm/utils/TableGen/Record.cpp
@@ -297,6 +297,20 @@ Init *BitsInit::resolveReferences(Record &R) {
return this;
}
+Init *IntInit::getBinaryOp(BinaryOp Op, Init *RHS) {
+ IntInit *RHSi = dynamic_cast<IntInit*>(RHS);
+ if (RHSi == 0) return 0;
+
+ int NewValue;
+ switch (Op) {
+ case SHL: NewValue = Value << RHSi->getValue(); break;
+ case SRA: NewValue = Value >> RHSi->getValue(); break;
+ case SRL: NewValue = (unsigned)Value >> (unsigned)RHSi->getValue(); break;
+ }
+ return new IntInit(NewValue);
+}
+
+
Init *IntInit::convertInitializerBitRange(const std::vector<unsigned> &Bits) {
BitsInit *BI = new BitsInit(Bits.size());
diff --git a/llvm/utils/TableGen/Record.h b/llvm/utils/TableGen/Record.h
index 9c5166c0cc8..82db72094b3 100644
--- a/llvm/utils/TableGen/Record.h
+++ b/llvm/utils/TableGen/Record.h
@@ -567,6 +567,8 @@ public:
}
virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
+ virtual Init *getBinaryOp(BinaryOp Op, Init *RHS);
+
virtual void print(std::ostream &OS) const { OS << Value; }
};
OpenPOWER on IntegriCloud