[llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y
Reid Spencer
reid at x10sys.com
Thu Mar 1 11:32:18 PST 2007
Changes in directory llvm/lib/AsmParser:
llvmAsmParser.y updated: 1.326 -> 1.327
---
Log message:
Use a simpler constructor when constructing ConstantInt. Also, replace
verbose code to sext/trunc or zext/trunc and APInt with new methods on
that class.
---
Diffs of the changes: (+9 -16)
llvmAsmParser.y | 25 +++++++++----------------
1 files changed, 9 insertions(+), 16 deletions(-)
Index: llvm/lib/AsmParser/llvmAsmParser.y
diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.326 llvm/lib/AsmParser/llvmAsmParser.y:1.327
--- llvm/lib/AsmParser/llvmAsmParser.y:1.326 Tue Feb 27 20:23:44 2007
+++ llvm/lib/AsmParser/llvmAsmParser.y Thu Mar 1 13:32:01 2007
@@ -1713,22 +1713,17 @@
GEN_ERROR("Constant value doesn't fit in type");
APInt Val(64, $2);
uint32_t BitWidth = cast<IntegerType>($1)->getBitWidth();
- if (BitWidth > 64)
- Val.sext(BitWidth);
- else if (BitWidth < 64)
- Val.trunc(BitWidth);
- $$ = ConstantInt::get($1, Val);
+ Val.sextOrTrunc(BitWidth);
+ $$ = ConstantInt::get(Val);
CHECK_FOR_ERROR
}
| IntType ESAPINTVAL { // arbitrary precision integer constants
uint32_t BitWidth = cast<IntegerType>($1)->getBitWidth();
if ($2->getBitWidth() > BitWidth) {
GEN_ERROR("Constant value does not fit in type");
- } else if ($2->getBitWidth() < BitWidth)
- $2->sext(BitWidth);
- else if ($2->getBitWidth() > BitWidth)
- $2->trunc(BitWidth);
- $$ = ConstantInt::get($1, *$2);
+ }
+ $2->sextOrTrunc(BitWidth);
+ $$ = ConstantInt::get(*$2);
delete $2;
CHECK_FOR_ERROR
}
@@ -1737,18 +1732,16 @@
GEN_ERROR("Constant value doesn't fit in type");
uint32_t BitWidth = cast<IntegerType>($1)->getBitWidth();
APInt Val(BitWidth, $2);
- $$ = ConstantInt::get($1, Val);
+ $$ = ConstantInt::get(Val);
CHECK_FOR_ERROR
}
| IntType EUAPINTVAL { // arbitrary precision integer constants
uint32_t BitWidth = cast<IntegerType>($1)->getBitWidth();
if ($2->getBitWidth() > BitWidth) {
GEN_ERROR("Constant value does not fit in type");
- } else if ($2->getBitWidth() < BitWidth)
- $2->zext(BitWidth);
- else if ($2->getBitWidth() > BitWidth)
- $2->trunc(BitWidth);
- $$ = ConstantInt::get($1, *$2);
+ }
+ $2->zextOrTrunc(BitWidth);
+ $$ = ConstantInt::get(*$2);
delete $2;
CHECK_FOR_ERROR
}
More information about the llvm-commits
mailing list