Cleaning up asserts and file/line macros.

This commit is contained in:
Ben Vanik
2014-07-12 16:51:52 -07:00
parent 840357413c
commit bf882714d0
92 changed files with 636 additions and 613 deletions

View File

@@ -23,12 +23,12 @@ void Block::AssertNoCycles() {
while ((hare = hare->next)) {
if (hare == tortoise) {
// Cycle!
XEASSERTALWAYS();
assert_always();
}
hare = hare->next;
if (hare == tortoise) {
// Cycle!
XEASSERTALWAYS();
assert_always();
}
tortoise = tortoise->next;
if (!hare || !tortoise) {

View File

@@ -114,7 +114,7 @@ void HIRBuilder::DumpValue(StringBuffer* str, Value* value) {
value->constant.v128.w);
break;
default:
XEASSERTALWAYS();
assert_always();
break;
}
} else {
@@ -276,12 +276,12 @@ void HIRBuilder::AssertNoCycles() {
while ((hare = hare->next)) {
if (hare == tortoise) {
// Cycle!
XEASSERTALWAYS();
assert_always();
}
hare = hare->next;
if (hare == tortoise) {
// Cycle!
XEASSERTALWAYS();
assert_always();
}
tortoise = tortoise->next;
if (!hare || !tortoise) {
@@ -937,7 +937,7 @@ Value* HIRBuilder::LoadConstant(const vec128_t& value) {
}
Value* HIRBuilder::LoadVectorShl(Value* sh) {
XEASSERT(sh->type == INT8_TYPE);
assert_true(sh->type == INT8_TYPE);
Instr* i =
AppendInstr(OPCODE_LOAD_VECTOR_SHL_info, 0, AllocValue(VEC128_TYPE));
i->set_src1(sh);
@@ -946,7 +946,7 @@ Value* HIRBuilder::LoadVectorShl(Value* sh) {
}
Value* HIRBuilder::LoadVectorShr(Value* sh) {
XEASSERT(sh->type == INT8_TYPE);
assert_true(sh->type == INT8_TYPE);
Instr* i =
AppendInstr(OPCODE_LOAD_VECTOR_SHR_info, 0, AllocValue(VEC128_TYPE));
i->set_src1(sh);
@@ -1050,7 +1050,7 @@ Value* HIRBuilder::Min(Value* value1, Value* value2) {
}
Value* HIRBuilder::Select(Value* cond, Value* value1, Value* value2) {
XEASSERT(cond->type == INT8_TYPE); // for now
assert_true(cond->type == INT8_TYPE); // for now
ASSERT_TYPES_EQUAL(value1, value2);
if (cond->IsConstant()) {
@@ -1233,7 +1233,7 @@ Value* HIRBuilder::Add(Value* value1, Value* value2,
Value* HIRBuilder::AddWithCarry(Value* value1, Value* value2, Value* value3,
uint32_t arithmetic_flags) {
ASSERT_TYPES_EQUAL(value1, value2);
XEASSERT(value3->type == INT8_TYPE);
assert_true(value3->type == INT8_TYPE);
Instr* i = AppendInstr(OPCODE_ADD_CARRY_info, arithmetic_flags,
AllocValue(value1->type));
@@ -1250,7 +1250,7 @@ Value* HIRBuilder::VectorAdd(Value* value1, Value* value2, TypeName part_type,
// This is shady.
uint32_t flags = part_type | (arithmetic_flags << 8);
XEASSERTZERO(flags >> 16);
assert_zero(flags >> 16);
Instr* i = AppendInstr(OPCODE_VECTOR_ADD_info, (uint16_t)flags,
AllocValue(value1->type));
@@ -1701,7 +1701,7 @@ Value* HIRBuilder::Permute(Value* control, Value* value1, Value* value2,
Value* HIRBuilder::Swizzle(Value* value, TypeName part_type,
uint32_t swizzle_mask) {
// For now.
XEASSERT(part_type == INT32_TYPE || part_type == FLOAT32_TYPE);
assert_true(part_type == INT32_TYPE || part_type == FLOAT32_TYPE);
if (swizzle_mask == SWIZZLE_XYZW_TO_XYZW) {
return Assign(value);

View File

@@ -36,7 +36,7 @@ void Value::RemoveUse(Use* use) {
}
uint32_t Value::AsUint32() {
XEASSERT(IsConstant());
assert_true(IsConstant());
switch (type) {
case INT8_TYPE:
return constant.i8;
@@ -47,13 +47,13 @@ uint32_t Value::AsUint32() {
case INT64_TYPE:
return (uint32_t)constant.i64;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
return 0;
}
}
uint64_t Value::AsUint64() {
XEASSERT(IsConstant());
assert_true(IsConstant());
switch (type) {
case INT8_TYPE:
return constant.i8;
@@ -64,14 +64,14 @@ uint64_t Value::AsUint64() {
case INT64_TYPE:
return constant.i64;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
return 0;
}
}
void Value::Cast(TypeName target_type) {
// TODO(benvanik): big matrix.
XEASSERTALWAYS();
assert_always();
}
void Value::ZeroExtend(TypeName target_type) {
@@ -89,7 +89,7 @@ void Value::ZeroExtend(TypeName target_type) {
constant.i64 = constant.i64 & 0xFFFFFFFF;
return;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
@@ -109,7 +109,7 @@ void Value::SignExtend(TypeName target_type) {
constant.i64 = constant.i8;
return;
default:
XEASSERTUNHANDLEDCASE(target_type);
assert_unhandled_case(target_type);
return;
}
case INT16_TYPE:
@@ -122,7 +122,7 @@ void Value::SignExtend(TypeName target_type) {
constant.i64 = constant.i16;
return;
default:
XEASSERTUNHANDLEDCASE(target_type);
assert_unhandled_case(target_type);
return;
}
case INT32_TYPE:
@@ -132,11 +132,11 @@ void Value::SignExtend(TypeName target_type) {
constant.i64 = constant.i32;
return;
default:
XEASSERTUNHANDLEDCASE(target_type);
assert_unhandled_case(target_type);
return;
}
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
return;
}
}
@@ -150,7 +150,7 @@ void Value::Truncate(TypeName target_type) {
constant.i64 = constant.i64 & 0xFF;
return;
default:
XEASSERTUNHANDLEDCASE(target_type);
assert_unhandled_case(target_type);
return;
}
case INT32_TYPE:
@@ -164,7 +164,7 @@ void Value::Truncate(TypeName target_type) {
constant.i64 = constant.i64 & 0xFFFF;
return;
default:
XEASSERTUNHANDLEDCASE(target_type);
assert_unhandled_case(target_type);
return;
}
case INT64_TYPE:
@@ -182,29 +182,29 @@ void Value::Truncate(TypeName target_type) {
constant.i64 = constant.i64 & 0xFFFFFFFF;
return;
default:
XEASSERTUNHANDLEDCASE(target_type);
assert_unhandled_case(target_type);
return;
}
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
return;
}
}
void Value::Convert(TypeName target_type, RoundMode round_mode) {
// TODO(benvanik): big matrix.
XEASSERTALWAYS();
assert_always();
}
void Value::Round(RoundMode round_mode) {
// TODO(benvanik): big matrix.
XEASSERTALWAYS();
assert_always();
}
bool Value::Add(Value* other) {
#define CHECK_DID_CARRY(v1, v2) (((uint64_t)v2) > ~((uint64_t)v1))
#define ADD_DID_CARRY(a, b) CHECK_DID_CARRY(a, b)
XEASSERT(type == other->type);
assert_true(type == other->type);
bool did_carry = false;
switch (type) {
case INT8_TYPE:
@@ -230,7 +230,7 @@ bool Value::Add(Value* other) {
constant.f64 += other->constant.f64;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
return did_carry;
@@ -238,7 +238,7 @@ bool Value::Add(Value* other) {
bool Value::Sub(Value* other) {
#define SUB_DID_CARRY(a, b) (b > a)
XEASSERT(type == other->type);
assert_true(type == other->type);
bool did_carry = false;
switch (type) {
case INT8_TYPE:
@@ -264,14 +264,14 @@ bool Value::Sub(Value* other) {
constant.f64 -= other->constant.f64;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
return did_carry;
}
void Value::Mul(Value* other) {
XEASSERT(type == other->type);
assert_true(type == other->type);
switch (type) {
case INT8_TYPE:
constant.i8 *= other->constant.i8;
@@ -292,13 +292,13 @@ void Value::Mul(Value* other) {
constant.f64 *= other->constant.f64;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
void Value::Div(Value* other) {
XEASSERT(type == other->type);
assert_true(type == other->type);
switch (type) {
case INT8_TYPE:
constant.i8 /= other->constant.i8;
@@ -319,19 +319,19 @@ void Value::Div(Value* other) {
constant.f64 /= other->constant.f64;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
void Value::MulAdd(Value* dest, Value* value1, Value* value2, Value* value3) {
// TODO(benvanik): big matrix.
XEASSERTALWAYS();
assert_always();
}
void Value::MulSub(Value* dest, Value* value1, Value* value2, Value* value3) {
// TODO(benvanik): big matrix.
XEASSERTALWAYS();
assert_always();
}
void Value::Neg() {
@@ -355,7 +355,7 @@ void Value::Neg() {
constant.f64 = -constant.f64;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
@@ -381,7 +381,7 @@ void Value::Abs() {
constant.f64 = abs(constant.f64);
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
@@ -395,7 +395,7 @@ void Value::Sqrt() {
constant.f64 = 1.0 / sqrt(constant.f64);
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
@@ -409,13 +409,13 @@ void Value::RSqrt() {
constant.f64 = sqrt(constant.f64);
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
void Value::And(Value* other) {
XEASSERT(type == other->type);
assert_true(type == other->type);
switch (type) {
case INT8_TYPE:
constant.i8 &= other->constant.i8;
@@ -430,13 +430,13 @@ void Value::And(Value* other) {
constant.i64 &= other->constant.i64;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
void Value::Or(Value* other) {
XEASSERT(type == other->type);
assert_true(type == other->type);
switch (type) {
case INT8_TYPE:
constant.i8 |= other->constant.i8;
@@ -451,13 +451,13 @@ void Value::Or(Value* other) {
constant.i64 |= other->constant.i64;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
void Value::Xor(Value* other) {
XEASSERT(type == other->type);
assert_true(type == other->type);
switch (type) {
case INT8_TYPE:
constant.i8 ^= other->constant.i8;
@@ -472,7 +472,7 @@ void Value::Xor(Value* other) {
constant.i64 ^= other->constant.i64;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
@@ -496,13 +496,13 @@ void Value::Not() {
constant.v128.high = ~constant.v128.high;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
void Value::Shl(Value* other) {
XEASSERT(other->type == INT8_TYPE);
assert_true(other->type == INT8_TYPE);
switch (type) {
case INT8_TYPE:
constant.i8 <<= other->constant.i8;
@@ -517,13 +517,13 @@ void Value::Shl(Value* other) {
constant.i64 <<= other->constant.i8;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
void Value::Shr(Value* other) {
XEASSERT(other->type == INT8_TYPE);
assert_true(other->type == INT8_TYPE);
switch (type) {
case INT8_TYPE:
constant.i8 = (uint8_t)constant.i8 >> other->constant.i8;
@@ -538,13 +538,13 @@ void Value::Shr(Value* other) {
constant.i64 = (uint16_t)constant.i64 >> other->constant.i8;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
void Value::Sha(Value* other) {
XEASSERT(other->type == INT8_TYPE);
assert_true(other->type == INT8_TYPE);
switch (type) {
case INT8_TYPE:
constant.i8 = constant.i8 >> other->constant.i8;
@@ -559,7 +559,7 @@ void Value::Sha(Value* other) {
constant.i64 = constant.i64 >> other->constant.i8;
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
@@ -584,7 +584,7 @@ void Value::ByteSwap() {
}
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
@@ -604,14 +604,14 @@ void Value::CountLeadingZeros(const Value* other) {
constant.i8 = poly::lzcnt(constant.i64);
break;
default:
XEASSERTUNHANDLEDCASE(type);
assert_unhandled_case(type);
break;
}
}
bool Value::Compare(Opcode opcode, Value* other) {
// TODO(benvanik): big matrix.
XEASSERTALWAYS();
assert_always();
return false;
}

View File

@@ -48,7 +48,7 @@ static size_t GetTypeSize(TypeName type_name) {
case VEC128_TYPE:
return 16;
default:
XEASSERTUNHANDLEDCASE(type_name);
assert_unhandled_case(type_name);
return 0;
}
}
@@ -177,13 +177,13 @@ class Value {
inline bool IsConstant() const { return !!(flags & VALUE_IS_CONSTANT); }
bool IsConstantTrue() const {
if (type == VEC128_TYPE) {
XEASSERTALWAYS();
assert_always();
}
return (flags & VALUE_IS_CONSTANT) && !!constant.i64;
}
bool IsConstantFalse() const {
if (type == VEC128_TYPE) {
XEASSERTALWAYS();
assert_always();
}
return (flags & VALUE_IS_CONSTANT) && !constant.i64;
}
@@ -196,20 +196,20 @@ class Value {
}
bool IsConstantEQ(Value* other) const {
if (type == VEC128_TYPE) {
XEASSERTALWAYS();
assert_always();
}
return (flags & VALUE_IS_CONSTANT) && (other->flags & VALUE_IS_CONSTANT) &&
constant.i64 == other->constant.i64;
}
bool IsConstantNE(Value* other) const {
if (type == VEC128_TYPE) {
XEASSERTALWAYS();
assert_always();
}
return (flags & VALUE_IS_CONSTANT) && (other->flags & VALUE_IS_CONSTANT) &&
constant.i64 != other->constant.i64;
}
bool IsConstantSLT(Value* other) const {
XEASSERT(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
assert_true(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
switch (type) {
case INT8_TYPE:
return constant.i8 < other->constant.i8;
@@ -224,12 +224,12 @@ class Value {
case FLOAT64_TYPE:
return constant.f64 < other->constant.f64;
default:
XEASSERTALWAYS();
assert_always();
return false;
}
}
bool IsConstantSLE(Value* other) const {
XEASSERT(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
assert_true(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
switch (type) {
case INT8_TYPE:
return constant.i8 <= other->constant.i8;
@@ -244,12 +244,12 @@ class Value {
case FLOAT64_TYPE:
return constant.f64 <= other->constant.f64;
default:
XEASSERTALWAYS();
assert_always();
return false;
}
}
bool IsConstantSGT(Value* other) const {
XEASSERT(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
assert_true(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
switch (type) {
case INT8_TYPE:
return constant.i8 > other->constant.i8;
@@ -264,12 +264,12 @@ class Value {
case FLOAT64_TYPE:
return constant.f64 > other->constant.f64;
default:
XEASSERTALWAYS();
assert_always();
return false;
}
}
bool IsConstantSGE(Value* other) const {
XEASSERT(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
assert_true(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
switch (type) {
case INT8_TYPE:
return constant.i8 >= other->constant.i8;
@@ -284,12 +284,12 @@ class Value {
case FLOAT64_TYPE:
return constant.f64 >= other->constant.f64;
default:
XEASSERTALWAYS();
assert_always();
return false;
}
}
bool IsConstantULT(Value* other) const {
XEASSERT(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
assert_true(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
switch (type) {
case INT8_TYPE:
return (uint8_t)constant.i8 < (uint8_t)other->constant.i8;
@@ -304,12 +304,12 @@ class Value {
case FLOAT64_TYPE:
return constant.f64 < other->constant.f64;
default:
XEASSERTALWAYS();
assert_always();
return false;
}
}
bool IsConstantULE(Value* other) const {
XEASSERT(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
assert_true(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
switch (type) {
case INT8_TYPE:
return (uint8_t)constant.i8 <= (uint8_t)other->constant.i8;
@@ -324,12 +324,12 @@ class Value {
case FLOAT64_TYPE:
return constant.f64 <= other->constant.f64;
default:
XEASSERTALWAYS();
assert_always();
return false;
}
}
bool IsConstantUGT(Value* other) const {
XEASSERT(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
assert_true(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
switch (type) {
case INT8_TYPE:
return (uint8_t)constant.i8 > (uint8_t)other->constant.i8;
@@ -344,12 +344,12 @@ class Value {
case FLOAT64_TYPE:
return constant.f64 > other->constant.f64;
default:
XEASSERTALWAYS();
assert_always();
return false;
}
}
bool IsConstantUGE(Value* other) const {
XEASSERT(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
assert_true(flags & VALUE_IS_CONSTANT && other->flags & VALUE_IS_CONSTANT);
switch (type) {
case INT8_TYPE:
return (uint8_t)constant.i8 >= (uint8_t)other->constant.i8;
@@ -364,7 +364,7 @@ class Value {
case FLOAT64_TYPE:
return constant.f64 >= other->constant.f64;
default:
XEASSERTALWAYS();
assert_always();
return false;
}
}