remove useless static_casts to retrieve ir::Value::type

This commit is contained in:
Joshua Warner 2014-05-01 12:47:38 -06:00
parent 479c056b2c
commit 86a98240b4

View File

@ -2354,7 +2354,7 @@ class MyCompiler: public Compiler {
{ {
// TODO: once type information is flowed properly, enable this assert. // TODO: once type information is flowed properly, enable this assert.
// Some time later, we can remove the parameter. // Some time later, we can remove the parameter.
// assert(&c, static_cast<Value*>(value)->type == type); // assert(&c, value->type == type);
compiler::push(&c, typeFootprint(&c, type), static_cast<Value*>(value)); compiler::push(&c, typeFootprint(&c, type), static_cast<Value*>(value));
} }
@ -2362,7 +2362,7 @@ class MyCompiler: public Compiler {
{ {
// TODO: once type information is flowed properly, enable this assert. // TODO: once type information is flowed properly, enable this assert.
// Some time later, we can remove the parameter. // Some time later, we can remove the parameter.
// assert(&c, static_cast<Value*>(value)->type == type); // assert(&c, value->type == type);
unsigned footprint = typeFootprint(&c, type); unsigned footprint = typeFootprint(&c, type);
c.saved = cons(&c, static_cast<Value*>(value), c.saved); c.saved = cons(&c, static_cast<Value*>(value), c.saved);
if (TargetBytesPerWord == 4 and footprint > 1) { if (TargetBytesPerWord == 4 and footprint > 1) {
@ -2638,17 +2638,17 @@ class MyCompiler: public Compiler {
virtual void store(ir::Type srcType, ir::Value* src, ir::Value* dst) virtual void store(ir::Type srcType, ir::Value* src, ir::Value* dst)
{ {
assert(&c, srcType.flavor() == static_cast<Value*>(src)->type.flavor()); assert(&c, srcType.flavor() == src->type.flavor());
assert(&c, srcType.flavor() == static_cast<Value*>(dst)->type.flavor()); assert(&c, srcType.flavor() == dst->type.flavor());
assert(&c, assert(&c,
srcType.flavor() != ir::Type::Float srcType.flavor() != ir::Type::Float || srcType.size()
|| srcType.size() == static_cast<Value*>(src)->type.size()); == src->type.size());
appendMove(&c, appendMove(&c,
lir::Move, lir::Move,
srcType.size(), srcType.size(),
srcType.size(), srcType.size(),
static_cast<Value*>(src), static_cast<Value*>(src),
static_cast<Value*>(dst)->type.size(), dst->type.size(),
static_cast<Value*>(dst)); static_cast<Value*>(dst));
} }
@ -2660,7 +2660,7 @@ class MyCompiler: public Compiler {
assert(&c, dstType.size() >= TargetBytesPerWord); assert(&c, dstType.size() >= TargetBytesPerWord);
assert(&c, srcType.flavor() == dstType.flavor()); assert(&c, srcType.flavor() == dstType.flavor());
Value* dst = value(&c, static_cast<Value*>(src)->type); Value* dst = value(&c, src->type);
appendMove(&c, appendMove(&c,
signExtend == ir::SignExtend ? lir::Move : lir::MoveZ, signExtend == ir::SignExtend ? lir::Move : lir::MoveZ,
srcType.size(), srcType.size(),
@ -2681,11 +2681,10 @@ class MyCompiler: public Compiler {
(isGeneralBranch(op) and isGeneralValue(a) and isGeneralValue(b))or( (isGeneralBranch(op) and isGeneralValue(a) and isGeneralValue(b))or(
isFloatBranch(op) and isFloatValue(a) and isFloatValue(b))); isFloatBranch(op) and isFloatValue(a) and isFloatValue(b)));
// assert(&c, type.flavor() == static_cast<Value*>(a)->type.flavor()); // assert(&c, type.flavor() == a->type.flavor());
// assert(&c, type.flavor() == static_cast<Value*>(b)->type.flavor()); // assert(&c, type.flavor() == b->type.flavor());
assert(&c, assert(&c,
static_cast<Value*>(address)->type address->type == ir::Type(ir::Type::Integer, TargetBytesPerWord));
== ir::Type(ir::Type::Integer, TargetBytesPerWord));
appendBranch(&c, appendBranch(&c,
op, op,
@ -2714,7 +2713,7 @@ class MyCompiler: public Compiler {
(isGeneralBinaryOp(op) and isGeneralValue(a) and isGeneralValue(b)) (isGeneralBinaryOp(op) and isGeneralValue(a) and isGeneralValue(b))
or(isFloatBinaryOp(op) and isFloatValue(a) and isFloatValue(b))); or(isFloatBinaryOp(op) and isFloatValue(a) and isFloatValue(b)));
Value* result = value(&c, static_cast<Value*>(a)->type); Value* result = value(&c, a->type);
appendCombine(&c, appendCombine(&c,
op, op,
@ -2734,7 +2733,7 @@ class MyCompiler: public Compiler {
assert(&c, assert(&c,
(isGeneralUnaryOp(op) and isGeneralValue(a))or(isFloatUnaryOp(op) (isGeneralUnaryOp(op) and isGeneralValue(a))or(isFloatUnaryOp(op)
and isFloatValue(a))); and isFloatValue(a)));
Value* result = value(&c, static_cast<Value*>(a)->type); Value* result = value(&c, a->type);
appendTranslate( appendTranslate(
&c, op, type.size(), static_cast<Value*>(a), type.size(), result); &c, op, type.size(), static_cast<Value*>(a), type.size(), result);
return result; return result;
@ -2742,7 +2741,7 @@ class MyCompiler: public Compiler {
virtual ir::Value* f2f(ir::Type aType, ir::Type resType, ir::Value* a) virtual ir::Value* f2f(ir::Type aType, ir::Type resType, ir::Value* a)
{ {
assert(&c, aType == static_cast<Value*>(a)->type); assert(&c, aType == a->type);
assert(&c, isFloatValue(a)); assert(&c, isFloatValue(a));
assert(&c, resType.flavor() == ir::Type::Float); assert(&c, resType.flavor() == ir::Type::Float);
assert(&c, aType.flavor() == ir::Type::Float); assert(&c, aType.flavor() == ir::Type::Float);
@ -2759,7 +2758,7 @@ class MyCompiler: public Compiler {
virtual ir::Value* f2i(ir::Type aType, ir::Type resType, ir::Value* a) virtual ir::Value* f2i(ir::Type aType, ir::Type resType, ir::Value* a)
{ {
// TODO: enable when possible // TODO: enable when possible
// assert(&c, aType == static_cast<Value*>(a)->type); // assert(&c, aType == a->type);
assert(&c, isFloatValue(a)); assert(&c, isFloatValue(a));
assert(&c, resType.flavor() != ir::Type::Float); assert(&c, resType.flavor() != ir::Type::Float);
assert(&c, aType.flavor() == ir::Type::Float); assert(&c, aType.flavor() == ir::Type::Float);
@ -2776,7 +2775,7 @@ class MyCompiler: public Compiler {
virtual ir::Value* i2f(ir::Type aType, ir::Type resType, ir::Value* a) virtual ir::Value* i2f(ir::Type aType, ir::Type resType, ir::Value* a)
{ {
// TODO: enable when possible // TODO: enable when possible
// assert(&c, aType == static_cast<Value*>(a)->type); // assert(&c, aType == a->type);
assert(&c, isGeneralValue(a)); assert(&c, isGeneralValue(a));
assert(&c, resType.flavor() == ir::Type::Float); assert(&c, resType.flavor() == ir::Type::Float);
assert(&c, aType.flavor() != ir::Type::Float); assert(&c, aType.flavor() != ir::Type::Float);