aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/NaCl/PromoteIntegers.cpp
diff options
context:
space:
mode:
authorDan Gohman <sunfish@google.com>2014-02-24 08:49:19 -0800
committerDan Gohman <sunfish@google.com>2014-02-25 11:58:56 -0800
commit338da97ed47659b9ef04f60067f84cafc93e3dd3 (patch)
tree2a80c78435712eafe02ea4afdc96c8d7713016cb /lib/Transforms/NaCl/PromoteIntegers.cpp
parent5653eb58d0b0068f0ef341c8928aa06d1d0ea3f7 (diff)
Support GEP and ConstantExprs directly in the JSBackend.
This patch also lays the groundwork for the single-use instruction trick to reduce the number of temporary variables.
Diffstat (limited to 'lib/Transforms/NaCl/PromoteIntegers.cpp')
-rw-r--r--lib/Transforms/NaCl/PromoteIntegers.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/Transforms/NaCl/PromoteIntegers.cpp b/lib/Transforms/NaCl/PromoteIntegers.cpp
index b8050b5ba2..af34faa7e5 100644
--- a/lib/Transforms/NaCl/PromoteIntegers.cpp
+++ b/lib/Transforms/NaCl/PromoteIntegers.cpp
@@ -233,14 +233,14 @@ class ConversionState {
Value *PromoteIntegers::splitLoad(LoadInst *Inst, ConversionState &State) {
if (Inst->isVolatile() || Inst->isAtomic())
report_fatal_error("Can't split volatile/atomic loads");
- if (cast<IntegerType>(Inst->getType())->getBitWidth() % 8 != 0)
+ if (DL->getTypeSizeInBits(Inst->getType()) % 8 != 0)
report_fatal_error("Loads must be a multiple of 8 bits");
Value *OrigPtr = State.getConverted(Inst->getPointerOperand());
// OrigPtr is a placeholder in recursive calls, and so has no name
if (OrigPtr->getName().empty())
OrigPtr->setName(Inst->getPointerOperand()->getName());
- unsigned Width = cast<IntegerType>(Inst->getType())->getBitWidth();
+ unsigned Width = DL->getTypeSizeInBits(Inst->getType());
Type *NewType = getPromotedType(Inst->getType());
unsigned LoWidth = Width;
@@ -293,8 +293,7 @@ Value *PromoteIntegers::splitLoad(LoadInst *Inst, ConversionState &State) {
Value *PromoteIntegers::splitStore(StoreInst *Inst, ConversionState &State) {
if (Inst->isVolatile() || Inst->isAtomic())
report_fatal_error("Can't split volatile/atomic stores");
- if (cast<IntegerType>(Inst->getValueOperand()->getType())->getBitWidth() % 8
- != 0)
+ if (DL->getTypeSizeInBits(Inst->getValueOperand()->getType()) % 8 != 0)
report_fatal_error("Stores must be a multiple of 8 bits");
Value *OrigPtr = State.getConverted(Inst->getPointerOperand());
@@ -302,8 +301,7 @@ Value *PromoteIntegers::splitStore(StoreInst *Inst, ConversionState &State) {
if (OrigPtr->getName().empty())
OrigPtr->setName(Inst->getPointerOperand()->getName());
Value *OrigVal = State.getConverted(Inst->getValueOperand());
- unsigned Width = cast<IntegerType>(
- Inst->getValueOperand()->getType())->getBitWidth();
+ unsigned Width = DL->getTypeSizeInBits(Inst->getValueOperand()->getType());
unsigned LoWidth = Width;
while (!isLegalSize(LoWidth)) LoWidth -= 8;