[llvm-commits] [dragonegg] r154702 - in /dragonegg/trunk: include/dragonegg/Trees.h src/Backend.cpp src/Constants.cpp src/Convert.cpp src/Debug.cpp src/DefaultABI.cpp src/Trees.cpp src/Types.cpp src/arm/Target.cpp src/x86/Target.cpp
Duncan Sands
baldrick at free.fr
Fri Apr 13 13:48:54 PDT 2012
Author: baldrick
Date: Fri Apr 13 15:48:54 2012
New Revision: 154702
URL: http://llvm.org/viewvc/llvm-project?rev=154702&view=rev
Log:
Introduce an "isa" method for testing tree codes, making it possible to write
"isa<INTEGER_TYPE>(type)" rather than "TREE_CODE(type) == INTEGER_TYPE".
Modified:
dragonegg/trunk/include/dragonegg/Trees.h
dragonegg/trunk/src/Backend.cpp
dragonegg/trunk/src/Constants.cpp
dragonegg/trunk/src/Convert.cpp
dragonegg/trunk/src/Debug.cpp
dragonegg/trunk/src/DefaultABI.cpp
dragonegg/trunk/src/Trees.cpp
dragonegg/trunk/src/Types.cpp
dragonegg/trunk/src/arm/Target.cpp
dragonegg/trunk/src/x86/Target.cpp
Modified: dragonegg/trunk/include/dragonegg/Trees.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Trees.h?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Trees.h (original)
+++ dragonegg/trunk/include/dragonegg/Trees.h Fri Apr 13 15:48:54 2012
@@ -36,6 +36,11 @@
// headers (and this one, as it may include GCC headers) are always included
// last.
+/// isa - Return true if the given tree has the specified code.
+template<enum tree_code code> bool isa(const_tree t) {
+ return TREE_CODE(t) == code;
+}
+
/// getDescriptiveName - Return a helpful name for the given tree, or an empty
/// string if no sensible name was found. These names are used to make the IR
/// more readable, and have no official status.
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Fri Apr 13 15:48:54 2012
@@ -807,7 +807,7 @@
tree val = TREE_VALUE(a);
// Assert its a string, and then get that string.
- assert(TREE_CODE(val) == STRING_CST &&
+ assert(isa<STRING_CST>(val) &&
"Annotate attribute arg should always be a string");
Constant *strGV = AddressOf(val);
Constant *Element[4] = {
@@ -834,7 +834,7 @@
// FIXME: DECL_PRESERVE_P indicates the var is marked with attribute 'used'.
// Global register variables don't turn into LLVM GlobalVariables.
- if (TREE_CODE(decl) == VAR_DECL && DECL_REGISTER(decl))
+ if (isa<VAR_DECL>(decl) && DECL_REGISTER(decl))
return;
// If we encounter a forward declaration then do not emit the global yet.
@@ -884,7 +884,7 @@
GV->setInitializer(Init);
// Set thread local (TLS)
- if (TREE_CODE(decl) == VAR_DECL && DECL_THREAD_LOCAL_P(decl))
+ if (isa<VAR_DECL>(decl) && DECL_THREAD_LOCAL_P(decl))
GV->setThreadLocal(true);
// Set the linkage.
@@ -939,7 +939,7 @@
handleVisibility(decl, GV);
// Set the section for the global.
- if (TREE_CODE(decl) == VAR_DECL) {
+ if (isa<VAR_DECL>(decl)) {
if (DECL_SECTION_NAME(decl)) {
GV->setSection(TREE_STRING_POINTER(DECL_SECTION_NAME(decl)));
#ifdef LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION
@@ -961,8 +961,7 @@
}
#ifdef TARGET_ADJUST_CSTRING_ALIGN
else if (DECL_INITIAL(decl) != error_mark_node && // uninitialized?
- DECL_INITIAL(decl) &&
- TREE_CODE(DECL_INITIAL(decl)) == STRING_CST) {
+ DECL_INITIAL(decl) && isa<STRING_CST>(DECL_INITIAL(decl))) {
TARGET_ADJUST_CSTRING_ALIGN(GV);
}
#endif
@@ -981,7 +980,7 @@
AddAnnotateAttrsToGlobal(GV, decl);
#ifdef LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION
- } else if (TREE_CODE(decl) == CONST_DECL) {
+ } else if (isa<CONST_DECL>(decl)) {
if (const char *Section =
LLVM_IMPLICIT_TARGET_GLOBAL_VAR_SECTION(decl)) {
GV->setSection(Section);
@@ -1063,9 +1062,9 @@
#ifndef NDEBUG
// Check that we are not being given an automatic variable or a type or label.
// A weak alias has TREE_PUBLIC set but not the other bits.
- if (TREE_CODE(decl) == PARM_DECL || TREE_CODE(decl) == RESULT_DECL ||
- TREE_CODE(decl) == TYPE_DECL || TREE_CODE(decl) == LABEL_DECL ||
- (TREE_CODE(decl) == VAR_DECL && !TREE_STATIC(decl) &&
+ if (isa<PARM_DECL>(decl) || isa<RESULT_DECL>(decl) ||
+ isa<TYPE_DECL>(decl) || isa<LABEL_DECL>(decl) ||
+ (isa<VAR_DECL>(decl) && !TREE_STATIC(decl) &&
!TREE_PUBLIC(decl) && !DECL_EXTERNAL(decl) && !DECL_REGISTER(decl))) {
debug_tree(decl);
llvm_unreachable("Cannot make a global for this kind of declaration!");
@@ -1079,7 +1078,7 @@
// Global register variable with asm name, e.g.:
// register unsigned long esp __asm__("ebp");
- if (TREE_CODE(decl) != FUNCTION_DECL && DECL_REGISTER(decl)) {
+ if (!isa<FUNCTION_DECL>(decl) && DECL_REGISTER(decl)) {
// This just verifies that the variable is ok. The actual "load/store"
// code paths handle accesses to the variable.
ValidateRegisterVariable(decl);
@@ -1089,7 +1088,7 @@
//TODO timevar_push(TV_LLVM_GLOBALS);
std::string Name;
- if (TREE_CODE(decl) != CONST_DECL) // CONST_DECLs do not have assembler names.
+ if (!isa<CONST_DECL>(decl)) // CONST_DECLs do not have assembler names.
Name = getLLVMAssemblerName(decl);
// Now handle ordinary static variables and functions (in memory).
@@ -1106,18 +1105,18 @@
// Specifying a section attribute on a variable forces it into a
// non-.bss section, and thus it cannot be common.
- if (TREE_CODE(decl) == VAR_DECL && DECL_SECTION_NAME(decl) != NULL_TREE &&
+ if (isa<VAR_DECL>(decl) && DECL_SECTION_NAME(decl) != NULL_TREE &&
DECL_INITIAL(decl) == NULL_TREE && DECL_COMMON(decl))
DECL_COMMON(decl) = 0;
// Variables can't be both common and weak.
- if (TREE_CODE(decl) == VAR_DECL && DECL_WEAK(decl))
+ if (isa<VAR_DECL>(decl) && DECL_WEAK(decl))
DECL_COMMON(decl) = 0;
// Okay, now we need to create an LLVM global variable or function for this
// object. Note that this is quite possibly a forward reference to the
// object, so its type may change later.
- if (TREE_CODE(decl) == FUNCTION_DECL) {
+ if (isa<FUNCTION_DECL>(decl)) {
assert(!Name.empty() && "Function with empty name!");
// If this function has already been created, reuse the decl. This happens
// when we have something like __builtin_memset and memset in the same file.
@@ -1165,8 +1164,8 @@
}
return SET_DECL_LLVM(decl, FnEntry);
} else {
- assert((TREE_CODE(decl) == VAR_DECL ||
- TREE_CODE(decl) == CONST_DECL) && "Not a function or var decl?");
+ assert((isa<VAR_DECL>(decl) ||
+ isa<CONST_DECL>(decl)) && "Not a function or var decl?");
Type *Ty = ConvertType(TREE_TYPE(decl));
GlobalVariable *GV ;
@@ -1234,7 +1233,7 @@
}
if ((TREE_READONLY(decl) && !TREE_SIDE_EFFECTS(decl)) ||
- TREE_CODE(decl) == CONST_DECL) {
+ isa<CONST_DECL>(decl)) {
if (DECL_EXTERNAL(decl)) {
// Mark external globals constant even though they could be marked
// non-constant in the defining translation unit. The definition of the
@@ -1250,13 +1249,13 @@
if (DECL_INITIAL(decl) != error_mark_node && // uninitialized?
DECL_INITIAL(decl) &&
(TREE_CONSTANT(DECL_INITIAL(decl)) ||
- TREE_CODE(DECL_INITIAL(decl)) == STRING_CST))
+ isa<STRING_CST>(DECL_INITIAL(decl))))
GV->setConstant(true);
}
}
// Set thread local (TLS)
- if (TREE_CODE(decl) == VAR_DECL && DECL_THREAD_LOCAL_P(decl))
+ if (isa<VAR_DECL>(decl) && DECL_THREAD_LOCAL_P(decl))
GV->setThreadLocal(true);
assert((GV->isDeclaration() || SizeOfGlobalMatchesDecl(GV, decl)) &&
@@ -1271,7 +1270,7 @@
/// GCC global will be output, and returns a declaration for it.
Value *make_definition_llvm(tree decl) {
// Only need to do something special for global variables.
- if (TREE_CODE(decl) != CONST_DECL && TREE_CODE(decl) != VAR_DECL)
+ if (!isa<CONST_DECL>(decl) && !isa<VAR_DECL>(decl))
return DECL_LLVM(decl);
// Do not allocate storage for external references (eg: a "weakref" alias).
if (DECL_EXTERNAL(decl))
@@ -1489,7 +1488,7 @@
while (IDENTIFIER_TRANSPARENT_ALIAS(target))
target = TREE_CHAIN(target);
- if (TREE_CODE(target) == IDENTIFIER_NODE) {
+ if (isa<IDENTIFIER_NODE>(target)) {
if (struct cgraph_node *fnode = cgraph_node_for_asm(target))
target = fnode->decl;
else if (struct varpool_node *vnode = varpool_node_for_asm(target))
@@ -1497,7 +1496,7 @@
}
GlobalValue *Aliasee = 0;
- if (TREE_CODE(target) == IDENTIFIER_NODE) {
+ if (isa<IDENTIFIER_NODE>(target)) {
if (!weakref) {
error("%q+D aliased to undefined symbol %qs", decl,
IDENTIFIER_POINTER(target));
@@ -1689,7 +1688,7 @@
// Emit any file-scope asms.
for (struct cgraph_asm_node *can = cgraph_asm_nodes; can; can = can->next) {
tree string = can->asm_str;
- if (TREE_CODE(string) == ADDR_EXPR)
+ if (isa<ADDR_EXPR>(string))
string = TREE_OPERAND(string, 0);
TheModule->appendModuleInlineAsm(TREE_STRING_POINTER (string));
}
@@ -1722,7 +1721,7 @@
// outputting block addresses when not compiling the function containing
// the block. We need to support outputting block addresses at odd times
// anyway since the GCC optimizers can generate these.
- if (TREE_CODE(decl) == VAR_DECL && !DECL_EXTERNAL(decl) &&
+ if (isa<VAR_DECL>(decl) && !DECL_EXTERNAL(decl) &&
(TREE_PUBLIC(decl) || DECL_PRESERVE_P(decl) ||
TREE_THIS_VOLATILE(decl)))
emit_global(decl);
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Fri Apr 13 15:48:54 2012
@@ -830,7 +830,7 @@
// Resize to the number of array elements if known. This ensures that every
// element will be at least default initialized even if no initial value is
// given for it.
- uint64_t TypeElts = TREE_CODE(init_type) == ARRAY_TYPE ?
+ uint64_t TypeElts = isa<ARRAY_TYPE>(init_type) ?
ArrayLengthOf(init_type) : TYPE_VECTOR_SUBPARTS(init_type);
if (TypeElts != NO_LENGTH)
Elts.resize(TypeElts);
@@ -838,7 +838,7 @@
// If GCC indices into the array need adjusting to make them zero indexed then
// record here the value to subtract off.
tree lower_bnd = NULL_TREE;
- if (TREE_CODE(init_type) == ARRAY_TYPE && TYPE_DOMAIN(init_type) &&
+ if (isa<ARRAY_TYPE>(init_type) && TYPE_DOMAIN(init_type) &&
!integer_zerop(TYPE_MIN_VALUE(TYPE_DOMAIN(init_type))))
lower_bnd = TYPE_MIN_VALUE(TYPE_DOMAIN(init_type));
@@ -871,7 +871,7 @@
unsigned FirstIndex, LastIndex;
if (!index) {
LastIndex = FirstIndex = NextIndex;
- } else if (TREE_CODE(index) == RANGE_EXPR) {
+ } else if (isa<RANGE_EXPR>(index)) {
tree first = TREE_OPERAND(index, 0);
tree last = TREE_OPERAND(index, 1);
@@ -974,7 +974,7 @@
// Make the IR more pleasant by returning as a vector if the GCC type was a
// vector. However this is only correct if the initial values had the same
// type as the vector element type, rather than some random other type.
- if (TREE_CODE(init_type) == VECTOR_TYPE && ActualEltTy == EltTy) {
+ if (isa<VECTOR_TYPE>(init_type) && ActualEltTy == EltTy) {
// If this is a vector of pointers, convert it to a vector of integers.
if (isa<PointerType>(EltTy)) {
IntegerType *IntPtrTy = getTargetData().getIntPtrType(Context);
@@ -1142,14 +1142,13 @@
// Record all interesting fields so they can easily be visited backwards.
SmallVector<tree, 16> Fields;
for (tree field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
- assert(TREE_CODE(field) == FIELD_DECL && "Lang data not freed?");
+ assert(isa<FIELD_DECL>(field) && "Lang data not freed?");
// Ignore fields with variable or unknown position since they cannot be
// default initialized.
if (!OffsetIsLLVMCompatible(field))
continue;
// Skip fields that are known not to be present.
- if (TREE_CODE(type) == QUAL_UNION_TYPE &&
- integer_zerop(DECL_QUALIFIER(field)))
+ if (isa<QUAL_UNION_TYPE>(type) && integer_zerop(DECL_QUALIFIER(field)))
continue;
Fields.push_back(field);
}
@@ -1203,13 +1202,13 @@
field = next_field;
while (1) {
assert(field && "Fell off end of record!");
- if (TREE_CODE(field) == FIELD_DECL) break;
+ if (isa<FIELD_DECL>(field)) break;
field = TREE_CHAIN(field);
}
}
next_field = TREE_CHAIN(field);
- assert(TREE_CODE(field) == FIELD_DECL && "Initial value not for a field!");
+ assert(isa<FIELD_DECL>(field) && "Initial value not for a field!");
assert(OffsetIsLLVMCompatible(field) && "Field position not known!");
// Turn the initial value for this field into an LLVM constant.
Constant *Init = ConvertInitializerWithCast(value, main_type(field),
@@ -1509,7 +1508,7 @@
tree array = TREE_OPERAND(exp, 0);
tree index = TREE_OPERAND(exp, 1);
tree index_type = main_type(index);
- assert(TREE_CODE(TREE_TYPE(array)) == ARRAY_TYPE && "Unknown ARRAY_REF!");
+ assert(isa<ARRAY_TYPE>(TREE_TYPE(array)) && "Unknown ARRAY_REF!");
// Check for variable sized reference.
assert(isSizeCompatible(main_type(main_type(array))) &&
@@ -1598,7 +1597,7 @@
// Figure out which function this is for, verify it's the one we're compiling.
if (DECL_CONTEXT(exp)) {
- assert(TREE_CODE(DECL_CONTEXT(exp)) == FUNCTION_DECL &&
+ assert(isa<FUNCTION_DECL>(DECL_CONTEXT(exp)) &&
"Address of label in nested function?");
assert(TheTreeToLLVM->getFUNCTION_DECL() == DECL_CONTEXT(exp) &&
"Taking the address of a label that isn't in the current fn!?");
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Fri Apr 13 15:48:54 2012
@@ -207,7 +207,7 @@
}
if (RegTy->isStructTy()) {
- assert(TREE_CODE(type) == COMPLEX_TYPE && "Expected a complex type!");
+ assert(isa<COMPLEX_TYPE>(type) && "Expected a complex type!");
assert(MemTy->isStructTy() && "Type mismatch!");
Value *RealPart = Builder.CreateExtractValue(V, 0);
Value *ImagPart = Builder.CreateExtractValue(V, 1);
@@ -220,7 +220,7 @@
}
if (RegTy->isVectorTy()) {
- assert(TREE_CODE(type) == VECTOR_TYPE && "Expected a vector type!");
+ assert(isa<VECTOR_TYPE>(type) && "Expected a vector type!");
assert(MemTy->isVectorTy() && "Type mismatch!");
Value *Res = UndefValue::get(RegTy);
unsigned NumElts = (unsigned)TYPE_VECTOR_SUBPARTS(type);
@@ -261,7 +261,7 @@
}
if (MemTy->isStructTy()) {
- assert(TREE_CODE(type) == COMPLEX_TYPE && "Expected a complex type!");
+ assert(isa<COMPLEX_TYPE>(type) && "Expected a complex type!");
assert(RegTy->isStructTy() && "Type mismatch!");
Value *RealPart = Builder.CreateExtractValue(V, 0);
Value *ImagPart = Builder.CreateExtractValue(V, 1);
@@ -274,7 +274,7 @@
}
if (MemTy->isVectorTy()) {
- assert(TREE_CODE(type) == VECTOR_TYPE && "Expected a vector type!");
+ assert(isa<VECTOR_TYPE>(type) && "Expected a vector type!");
assert(RegTy->isVectorTy() && "Type mismatch!");
Value *Res = UndefValue::get(MemTy);
unsigned NumElts = (unsigned)TYPE_VECTOR_SUBPARTS(type);
@@ -298,9 +298,9 @@
// The range of possible values is TYPE_MIN_VALUE .. TYPE_MAX_VALUE.
tree min = TYPE_MIN_VALUE(type);
- assert(min && TREE_CODE(min) == INTEGER_CST && "Min not a constant!");
+ assert(min && isa<INTEGER_CST>(min) && "Min not a constant!");
tree max = TYPE_MAX_VALUE(type);
- assert(max && TREE_CODE(max) == INTEGER_CST && "Max not a constant!");
+ assert(max && isa<INTEGER_CST>(max) && "Max not a constant!");
unsigned BitWidth = GET_MODE_BITSIZE(TYPE_MODE(type));
@@ -351,9 +351,9 @@
case COMPLEX_TYPE:
case VECTOR_TYPE: {
- assert((TREE_CODE(type) != COMPLEX_TYPE || RegTy->isStructTy()) &&
+ assert((!isa<COMPLEX_TYPE>(type) || RegTy->isStructTy()) &&
"Expected a struct type!");
- assert((TREE_CODE(type) != VECTOR_TYPE || RegTy->isVectorTy()) &&
+ assert((!isa<VECTOR_TYPE>(type) || RegTy->isVectorTy()) &&
"Expected a vector type!");
tree elt_type = main_type(type);
Type *EltRegTy = getRegType(elt_type);
@@ -616,12 +616,12 @@
assert(HAS_RTL_P(decl) && "Expected a declaration with RTL!");
return
// GCC bug workaround: RESULT_DECL may not have DECL_CONTEXT set in thunks.
- (!DECL_CONTEXT(decl) && TREE_CODE(decl) == RESULT_DECL) ||
+ (!DECL_CONTEXT(decl) && isa<RESULT_DECL>(decl)) ||
// Usual case.
(DECL_CONTEXT(decl) == current_function_decl &&
!DECL_EXTERNAL(decl) && // External variables are not local.
!TREE_STATIC(decl) && // Static variables not considered local.
- TREE_CODE(decl) != FUNCTION_DECL); // Nested functions not considered local.
+ !isa<FUNCTION_DECL>(decl)); // Nested functions not considered local.
}
/// set_decl_local - Remember the LLVM value for a GCC declaration.
@@ -773,7 +773,7 @@
}
// Otherwise, this must be something returned with NRVO.
- assert(TREE_CODE(TREE_TYPE(ResultDecl)) == REFERENCE_TYPE &&
+ assert(isa<REFERENCE_TYPE>(TREE_TYPE(ResultDecl)) &&
"Not type match and not passing by reference?");
// Create an alloca for the ResultDecl.
Value *Tmp = TheTreeToLLVM->CreateTemporary(AI->getType());
@@ -1172,7 +1172,7 @@
/// given scope.
void TreeToLLVM::EmitVariablesInScope(tree scope) {
for (tree t = BLOCK_VARS(scope); t; t = TREE_CHAIN (t))
- if (TREE_CODE(t) == VAR_DECL)
+ if (isa<VAR_DECL>(t))
// If this is just the rotten husk of a variable that the gimplifier
// eliminated all uses of, but is preserving for debug info, ignore it.
if (!DECL_HAS_VALUE_EXPR_P(t))
@@ -1185,7 +1185,7 @@
/// DefineSSAName - Use the given value as the definition of the given SSA name.
/// Returns the provided value as a convenience.
Value *TreeToLLVM::DefineSSAName(tree reg, Value *Val) {
- assert(TREE_CODE(reg) == SSA_NAME && "Not an SSA name!");
+ assert(isa<SSA_NAME>(reg) && "Not an SSA name!");
if (Value *ExistingValue = SSANames[reg]) {
if (Val != ExistingValue) {
assert(isSSAPlaceholder(ExistingValue) && "Multiply defined SSA name!");
@@ -1324,7 +1324,7 @@
if (!Fn->getReturnType()->isVoidTy()) {
tree TreeRetVal = DECL_RESULT(FnDecl);
if (!AGGREGATE_TYPE_P(TREE_TYPE(TreeRetVal)) &&
- TREE_CODE(TREE_TYPE(TreeRetVal)) != COMPLEX_TYPE) {
+ !isa<COMPLEX_TYPE>(TREE_TYPE(TreeRetVal))) {
// If the DECL_RESULT is a scalar type, just load out the return value
// and return it.
Value *RetVal = Builder.CreateLoad(DECL_LOCAL(TreeRetVal), "retval");
@@ -1463,7 +1463,7 @@
/// getLabelDeclBlock - Lazily get and create a basic block for the specified
/// label.
BasicBlock *TreeToLLVM::getLabelDeclBlock(tree LabelDecl) {
- assert(TREE_CODE(LabelDecl) == LABEL_DECL && "Isn't a label!?");
+ assert(isa<LABEL_DECL>(LabelDecl) && "Isn't a label!?");
if (DECL_LOCAL_SET_P(LabelDecl))
return cast<BasicBlock>(DECL_LOCAL(LabelDecl));
@@ -1502,7 +1502,7 @@
// The phi defines the associated ssa name.
tree name = gimple_phi_result(gcc_phi);
- assert(TREE_CODE(name) == SSA_NAME && "PHI result not an SSA name!");
+ assert(isa<SSA_NAME>(name) && "PHI result not an SSA name!");
if (flag_verbose_asm)
NameValue(PHI, name);
DefineSSAName(name, PHI);
@@ -1619,7 +1619,7 @@
/// DestLoc.
void TreeToLLVM::EmitAggregate(tree exp, const MemRef &DestLoc) {
assert(AGGREGATE_TYPE_P(TREE_TYPE(exp)) && "Expected an aggregate type!");
- if (TREE_CODE(exp) == CONSTRUCTOR) {
+ if (isa<CONSTRUCTOR>(exp)) {
EmitCONSTRUCTOR(exp, &DestLoc);
return;
}
@@ -1882,11 +1882,11 @@
return 1;
// The cost of a record type is the sum of the costs of its fields.
- if (TREE_CODE(type) == RECORD_TYPE) {
+ if (isa<RECORD_TYPE>(type)) {
Type *Ty = ConvertType(type);
unsigned TotalCost = 0;
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
- assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?");
+ assert(isa<FIELD_DECL>(Field) && "Lang data not freed?");
// If the field has no size, for example because it is a C-style variable
// length array, then just give up.
if (!DECL_SIZE(Field))
@@ -1910,7 +1910,7 @@
}
// For array types, multiply the array length by the component cost.
- if (TREE_CODE(type) == ARRAY_TYPE) {
+ if (isa<ARRAY_TYPE>(type)) {
// If this is an array with a funky component type then just give up.
if (!isSizeCompatible(TREE_TYPE(type)))
return TooCostly;
@@ -1940,7 +1940,7 @@
return;
}
- if (TREE_CODE(type) == RECORD_TYPE) {
+ if (isa<RECORD_TYPE>(type)) {
// Ensure the source and destination are pointers to the record type.
Type *Ty = ConvertType(type);
DestLoc.Ptr = Builder.CreateBitCast(DestLoc.Ptr, Ty->getPointerTo());
@@ -1973,7 +1973,7 @@
return;
}
- assert(TREE_CODE(type) == ARRAY_TYPE && "Expected an array!");
+ assert(isa<ARRAY_TYPE>(type) && "Expected an array!");
// Turn the source and destination into pointers to the component type.
Type *CompType = ConvertType(TREE_TYPE(type));
@@ -2038,7 +2038,7 @@
return;
}
- if (TREE_CODE(type) == RECORD_TYPE) {
+ if (isa<RECORD_TYPE>(type)) {
// Ensure the pointer is to the record type.
Type *Ty = ConvertType(type);
DestLoc.Ptr = Builder.CreateBitCast(DestLoc.Ptr, Ty->getPointerTo());
@@ -2065,7 +2065,7 @@
return;
}
- assert(TREE_CODE(type) == ARRAY_TYPE && "Expected an array!");
+ assert(isa<ARRAY_TYPE>(type) && "Expected an array!");
// Turn the pointer into a pointer to the component type.
Type *CompType = ConvertType(TREE_TYPE(type));
@@ -2218,7 +2218,7 @@
tree val = TREE_VALUE(a);
// Assert its a string, and then get that string.
- assert(TREE_CODE(val) == STRING_CST &&
+ assert(isa<STRING_CST>(val) &&
"Annotate attribute arg should always be a string");
Constant *strGV = AddressOf(val);
Value *Ops[4] = {
@@ -2247,7 +2247,7 @@
void TreeToLLVM::EmitAutomaticVariableDecl(tree decl) {
// If this is just the rotten husk of a variable that the gimplifier
// eliminated all uses of, but is preserving for debug info, ignore it.
- if (TREE_CODE(decl) == VAR_DECL && DECL_HAS_VALUE_EXPR_P(decl))
+ if (isa<VAR_DECL>(decl) && DECL_HAS_VALUE_EXPR_P(decl))
return;
tree type = TREE_TYPE(decl);
@@ -2259,7 +2259,7 @@
return; // Error message was already done; now avoid a crash.
debug_tree(decl);
llvm_unreachable("Initializer will decide the size of this array?");
- } else if (TREE_CODE(DECL_SIZE_UNIT(decl)) == INTEGER_CST) {
+ } else if (isa<INTEGER_CST>(DECL_SIZE_UNIT(decl))) {
// Variable of fixed size that goes on the stack.
Ty = ConvertType(type);
} else {
@@ -2311,7 +2311,7 @@
if (DECL_NAME(decl)) {
TheDebugInfo->EmitDeclare(decl, dwarf::DW_TAG_auto_variable,
AI->getName(), TREE_TYPE(decl), AI, Builder);
- } else if (TREE_CODE(decl) == RESULT_DECL) {
+ } else if (isa<RESULT_DECL>(decl)) {
TheDebugInfo->EmitDeclare(decl, dwarf::DW_TAG_return_variable,
AI->getName(), TREE_TYPE(decl), AI, Builder);
}
@@ -2331,7 +2331,7 @@
if (TYPE_P (type))
type = lookup_type_for_runtime (type);
STRIP_NOPS(type);
- if (TREE_CODE(type) == ADDR_EXPR)
+ if (isa<ADDR_EXPR>(type))
type = TREE_OPERAND(type, 0);
return AddressOf(type);
}
@@ -2673,7 +2673,7 @@
static bool canEmitRegisterVariable(tree exp) {
// Only variables can be marked as 'register'.
- if (TREE_CODE(exp) != VAR_DECL || !DECL_REGISTER(exp))
+ if (!isa<VAR_DECL>(exp) || !DECL_REGISTER(exp))
return false;
// We can emit inline assembler for access to global register variables.
@@ -3436,7 +3436,7 @@
#endif
va_end(ops);
- Type *RetTy = TREE_CODE(ret_type) == VOID_TYPE ?
+ Type *RetTy = isa<VOID_TYPE>(ret_type) ?
Type::getVoidTy(Context) : getRegType(ret_type);
// The LLVM argument types.
@@ -3776,7 +3776,7 @@
// Look for hard register operand. This matches only a constraint of a
// register class that includes that hard register, and it matches that
// perfectly, so we never return 0 in this case.
- if (TREE_CODE(Operand) == VAR_DECL && DECL_HARD_REGISTER(Operand)) {
+ if (isa<VAR_DECL>(Operand) && DECL_HARD_REGISTER(Operand)) {
int RegNum = decode_reg_name(extractRegisterName(Operand));
RetVal = -1;
if (RegNum >= 0) {
@@ -3798,7 +3798,7 @@
// Look for integer constant operand. This cannot match "m", and "i" is
// better than "r". FIXME target-dependent immediate letters are not handled
// yet; in general they require looking at the value.
- if (TREE_CODE(Operand) == INTEGER_CST) {
+ if (isa<INTEGER_CST>(Operand)) {
do {
RetVal = -1;
if (*p == 'i' || *p == 'n') { // integer constant
@@ -4218,7 +4218,7 @@
}
tree ObjSizeTree = gimple_call_arg(stmt, 1);
STRIP_NOPS (ObjSizeTree);
- if (TREE_CODE (ObjSizeTree) != INTEGER_CST
+ if (!isa<INTEGER_CST>(ObjSizeTree)
|| tree_int_cst_sgn (ObjSizeTree) < 0
|| compare_tree_int (ObjSizeTree, 3) > 0) {
error("Invalid second builtin_object_size argument");
@@ -4909,7 +4909,7 @@
if (validate_gimple_arglist(stmt, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) {
tree value = gimple_call_arg(stmt, 1);
- if (TREE_CODE(value) != INTEGER_CST ||
+ if (!isa<INTEGER_CST>(value) ||
cast<ConstantInt>(EmitMemory(value))->getValue() != 1) {
error ("%<__builtin_longjmp%> second argument must be 1");
return false;
@@ -5551,7 +5551,7 @@
tree which = gimple_call_arg(stmt, 0);
unsigned HOST_WIDE_INT iwhich;
- if (TREE_CODE (which) != INTEGER_CST) {
+ if (!isa<INTEGER_CST>(which)) {
error ("argument of %<__builtin_eh_return_regno%> must be constant");
return false;
}
@@ -5847,7 +5847,7 @@
tree val = TREE_VALUE(a);
// Assert its a string, and then get that string.
- assert(TREE_CODE(val) == STRING_CST &&
+ assert(isa<STRING_CST>(val) &&
"Annotate attribute arg should always be a string");
Constant *strGV = AddressOf(val);
@@ -5888,7 +5888,7 @@
tree IndexType = TREE_TYPE(Index);
tree ElementType = TREE_TYPE(ArrayTreeType);
- assert(TREE_CODE (ArrayTreeType) == ARRAY_TYPE && "Unknown ARRAY_REF!");
+ assert(isa<ARRAY_TYPE>(ArrayTreeType) && "Unknown ARRAY_REF!");
Value *ArrayAddr;
unsigned ArrayAlign;
@@ -6003,9 +6003,9 @@
tree FieldDecl = TREE_OPERAND(exp, 1);
unsigned LVAlign = StructAddrLV.getAlignment();
- assert((TREE_CODE(DECL_CONTEXT(FieldDecl)) == RECORD_TYPE ||
- TREE_CODE(DECL_CONTEXT(FieldDecl)) == UNION_TYPE ||
- TREE_CODE(DECL_CONTEXT(FieldDecl)) == QUAL_UNION_TYPE));
+ assert((isa<RECORD_TYPE>(DECL_CONTEXT(FieldDecl)) ||
+ isa<UNION_TYPE>(DECL_CONTEXT(FieldDecl)) ||
+ isa<QUAL_UNION_TYPE>(DECL_CONTEXT(FieldDecl))));
Type *StructTy = ConvertType(DECL_CONTEXT(FieldDecl));
@@ -6088,8 +6088,7 @@
}
assert(BitStart < 8 && "Bit offset not properly incorporated in the pointer");
- assert(DECL_SIZE(FieldDecl) &&
- TREE_CODE(DECL_SIZE(FieldDecl)) == INTEGER_CST &&
+ assert(DECL_SIZE(FieldDecl) && isa<INTEGER_CST>(DECL_SIZE(FieldDecl)) &&
"Variable sized bitfield?");
unsigned BitfieldSize = TREE_INT_CST_LOW(DECL_SIZE(FieldDecl));
return LValue(FieldPtr, LVAlign, BitStart, BitfieldSize);
@@ -6286,7 +6285,7 @@
/// EmitMinInvariant - The given value is constant in this function. Return the
/// corresponding LLVM value. Only creates code in the entry block.
Value *TreeToLLVM::EmitMinInvariant(tree reg) {
- Value *V = (TREE_CODE(reg) == ADDR_EXPR) ?
+ Value *V = isa<ADDR_EXPR>(reg) ?
EmitInvariantAddress(reg) : EmitRegisterConstant(reg);
assert(V->getType() == getRegType(TREE_TYPE(reg)) &&
"Gimple min invariant has wrong type!");
@@ -6320,7 +6319,7 @@
Builder.SetInsertPoint(EntryBlock);
// Calculate the address.
- assert(TREE_CODE(addr) == ADDR_EXPR && "Invariant address not ADDR_EXPR!");
+ assert(isa<ADDR_EXPR>(addr) && "Invariant address not ADDR_EXPR!");
Value *Address = EmitADDR_EXPR(addr);
// Restore the entry block terminator.
@@ -6536,9 +6535,8 @@
/// EmitRegister - Convert the specified gimple register or local constant of
/// register type to an LLVM value. Only creates code in the entry block.
Value *TreeToLLVM::EmitRegister(tree reg) {
- while (TREE_CODE(reg) == OBJ_TYPE_REF) reg = OBJ_TYPE_REF_EXPR(reg);
- return (TREE_CODE(reg) == SSA_NAME) ?
- EmitReg_SSA_NAME(reg) : EmitMinInvariant(reg);
+ while (isa<OBJ_TYPE_REF>(reg)) reg = OBJ_TYPE_REF_EXPR(reg);
+ return isa<SSA_NAME>(reg) ? EmitReg_SSA_NAME(reg) : EmitMinInvariant(reg);
}
/// EmitReg_SSA_NAME - Return the defining value of the given SSA_NAME.
@@ -6568,7 +6566,7 @@
assert(SSA_VAR_P(var) && "Not an SSA variable!");
// If the variable is itself an ssa name, use its LLVM value.
- if (TREE_CODE (var) == SSA_NAME) {
+ if (isa<SSA_NAME>(var)) {
Value *Val = EmitReg_SSA_NAME(var);
assert(Val->getType() == getRegType(TREE_TYPE(reg)) &&
"SSA name has wrong type!");
@@ -6580,9 +6578,9 @@
// variable in the function is a read operation, and refers to the value
// read, it has an undefined value for VAR_DECLs (a RESULT_DECL can have
// an initial value if the function returns a class by value).
- assert((TREE_CODE(var) == PARM_DECL || TREE_CODE(var) == RESULT_DECL ||
- TREE_CODE(var) == VAR_DECL) && "Unsupported SSA name definition!");
- if (TREE_CODE(var) == VAR_DECL)
+ assert((isa<PARM_DECL>(var) || isa<RESULT_DECL>(var) ||
+ isa<VAR_DECL>(var)) && "Unsupported SSA name definition!");
+ if (isa<VAR_DECL>(var))
return DefineSSAName(reg, UndefValue::get(getRegType(TREE_TYPE(reg))));
// Read the initial value of the parameter and associate it with the ssa name.
@@ -6619,7 +6617,7 @@
return Builder.CreateSelect(Cmp, Op, OpN, Op->getName()+"abs");
}
- if (TREE_CODE(TREE_TYPE(op)) == VECTOR_TYPE) {
+ if (isa<VECTOR_TYPE>(TREE_TYPE(op))) {
// Clear the sign bits.
Value *Op = EmitRegister(op);
VectorType *VecTy = cast<VectorType>(Op->getType());
@@ -6691,7 +6689,7 @@
Value *V = EmitRegister(op);
tree type = TREE_TYPE(op);
- if (TREE_CODE(type) == COMPLEX_TYPE) {
+ if (isa<COMPLEX_TYPE>(type)) {
tree elt_type = TREE_TYPE(type);
Value *R, *I; SplitComplex(V, R, I);
@@ -6773,7 +6771,7 @@
case LTGT_EXPR: FPPred = CmpInst::FCMP_ONE; break;
}
- if (TREE_CODE(TREE_TYPE(lhs)) == COMPLEX_TYPE) {
+ if (isa<COMPLEX_TYPE>(TREE_TYPE(lhs))) {
Value *LHSr, *LHSi;
SplitComplex(LHS, LHSr, LHSi);
Value *RHSr, *RHSi;
@@ -7212,7 +7210,7 @@
Value *RHS = EmitRegister(op1);
tree type = TREE_TYPE(op0);
- if (TREE_CODE(type) == COMPLEX_TYPE) {
+ if (isa<COMPLEX_TYPE>(type)) {
tree elt_type = TREE_TYPE(type);
Value *LHSr, *LHSi; SplitComplex(LHS, LHSr, LHSi);
Value *RHSr, *RHSi; SplitComplex(RHS, RHSr, RHSi);
@@ -7232,7 +7230,7 @@
Value *RHS = EmitRegister(op1);
tree type = TREE_TYPE(op0);
- if (TREE_CODE(type) == COMPLEX_TYPE) {
+ if (isa<COMPLEX_TYPE>(type)) {
tree elt_type = TREE_TYPE(type);
Value *LHSr, *LHSi; SplitComplex(LHS, LHSr, LHSi);
Value *RHSr, *RHSi; SplitComplex(RHS, RHSr, RHSi);
@@ -7272,7 +7270,7 @@
Value *RHS = EmitRegister(op1);
tree type = TREE_TYPE(op0);
- if (TREE_CODE(type) == COMPLEX_TYPE) {
+ if (isa<COMPLEX_TYPE>(type)) {
tree elt_type = TREE_TYPE(type);
Value *LHSr, *LHSi; SplitComplex(LHS, LHSr, LHSi);
Value *RHSr, *RHSi; SplitComplex(RHS, RHSr, RHSi);
@@ -7302,7 +7300,7 @@
Value *RHS = EmitRegister(op1);
tree type = TREE_TYPE(op0);
- if (TREE_CODE(type) == COMPLEX_TYPE) {
+ if (isa<COMPLEX_TYPE>(type)) {
Value *LHSr, *LHSi; SplitComplex(LHS, LHSr, LHSi);
Value *RHSr, *RHSi; SplitComplex(RHS, RHSr, RHSi);
Value *DSTr, *DSTi;
@@ -7421,7 +7419,7 @@
Value *RHS = EmitRegister(op1);
tree type = TREE_TYPE(op0);
- if (TREE_CODE(type) == COMPLEX_TYPE) {
+ if (isa<COMPLEX_TYPE>(type)) {
tree elt_type = TREE_TYPE(type);
Value *LHSr, *LHSi; SplitComplex(LHS, LHSr, LHSi);
Value *RHSr, *RHSi; SplitComplex(RHS, RHSr, RHSi);
@@ -7785,7 +7783,7 @@
std::string SimplifiedConstraint;
// If this output register is pinned to a machine register, use that machine
// register instead of the specified constraint.
- if (TREE_CODE(Operand) == VAR_DECL && DECL_HARD_REGISTER(Operand)) {
+ if (isa<VAR_DECL>(Operand) && DECL_HARD_REGISTER(Operand)) {
const char* RegName = extractRegisterName(Operand);
int RegNum = decode_reg_name(RegName);
if (RegNum >= 0) {
@@ -7813,7 +7811,7 @@
LValue Dest;
Type *DestValTy = ConvertType(TREE_TYPE(Operand));
- if (TREE_CODE(Operand) == SSA_NAME) {
+ if (isa<SSA_NAME>(Operand)) {
// The ASM is defining an ssa name. Store the output to a temporary, then
// load it out again later as the ssa name.
MemRef TmpLoc = CreateTempLoc(DestValTy);
@@ -7862,13 +7860,12 @@
Value *Op = 0;
Type *OpTy = LLVMTy;
if (LLVMTy->isSingleValueType()) {
- if (TREE_CODE(Val)==ADDR_EXPR &&
- TREE_CODE(TREE_OPERAND(Val,0))==LABEL_DECL) {
+ if (isa<ADDR_EXPR>(Val) && isa<LABEL_DECL>(TREE_OPERAND(Val,0))) {
// Emit the label, but do not assume it is going to be the target
// of an indirect branch. Having this logic here is a hack; there
// should be a bit in the label identifying it as in an asm.
Op = getLabelDeclBlock(TREE_OPERAND(Val, 0));
- } else if (TREE_CODE(Val) == VAR_DECL && DECL_HARD_REGISTER(Val)) {
+ } else if (isa<VAR_DECL>(Val) && DECL_HARD_REGISTER(Val)) {
// GCC special cases hard registers used as inputs to asm statements.
// Emit an inline asm node that copies the value out of the specified
// register.
@@ -7986,7 +7983,7 @@
// If this input register is pinned to a machine register, use that machine
// register instead of the specified constraint.
- if (TREE_CODE(Val) == VAR_DECL && DECL_HARD_REGISTER(Val)) {
+ if (isa<VAR_DECL>(Val) && DECL_HARD_REGISTER(Val)) {
const char *RegName = extractRegisterName(Val);
int RegNum = decode_reg_name(RegName);
if (RegNum >= 0) {
@@ -8277,7 +8274,7 @@
void TreeToLLVM::RenderGIMPLE_GOTO(gimple stmt) {
tree dest = gimple_goto_dest(stmt);
- if (TREE_CODE(dest) == LABEL_DECL) {
+ if (isa<LABEL_DECL>(dest)) {
// Direct branch.
Builder.CreateBr(getLabelDeclBlock(dest));
return;
@@ -8667,8 +8664,8 @@
tree call_expr = gimple_call_fn(stmt);
assert(TREE_TYPE (call_expr) &&
- (TREE_CODE(TREE_TYPE (call_expr)) == POINTER_TYPE ||
- TREE_CODE(TREE_TYPE (call_expr)) == REFERENCE_TYPE)
+ (isa<POINTER_TYPE>(TREE_TYPE (call_expr)) ||
+ isa<REFERENCE_TYPE>(TREE_TYPE (call_expr)))
&& "Not calling a function pointer?");
tree function_type = TREE_TYPE(TREE_TYPE (call_expr));
@@ -8717,7 +8714,7 @@
RHS = TriviallyTypeConvert(RHS, getRegType(TREE_TYPE(lhs)));
// If this is the definition of an ssa name, record it in the SSANames map.
- if (TREE_CODE(lhs) == SSA_NAME) {
+ if (isa<SSA_NAME>(lhs)) {
if (flag_verbose_asm)
NameValue(RHS, lhs);
DefineSSAName(lhs, RHS);
Modified: dragonegg/trunk/src/Debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Debug.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/Debug.cpp (original)
+++ dragonegg/trunk/src/Debug.cpp Fri Apr 13 15:48:54 2012
@@ -85,7 +85,7 @@
/// NodeSizeInBits - Returns the size in bits stored in a tree node regardless
/// of whether the node is a TYPE or DECL.
static uint64_t NodeSizeInBits(tree Node) {
- if (TREE_CODE(Node) == ERROR_MARK) {
+ if (isa<ERROR_MARK>(Node)) {
return BITS_PER_WORD;
} else if (TYPE_P(Node)) {
if (TYPE_SIZE(Node) == NULL_TREE)
@@ -109,7 +109,7 @@
/// NodeAlignInBits - Returns the alignment in bits stored in a tree node
/// regardless of whether the node is a TYPE or DECL.
static uint64_t NodeAlignInBits(tree Node) {
- if (TREE_CODE(Node) == ERROR_MARK) return BITS_PER_WORD;
+ if (isa<ERROR_MARK>(Node)) return BITS_PER_WORD;
if (TYPE_P(Node)) return TYPE_ALIGN(Node);
if (DECL_P(Node)) return DECL_ALIGN(Node);
return BITS_PER_WORD;
@@ -118,7 +118,7 @@
/// FieldType - Returns the type node of a structure member field.
///
static tree FieldType(tree Field) {
- if (TREE_CODE (Field) == ERROR_MARK) return integer_type_node;
+ if (isa<ERROR_MARK>(Field)) return integer_type_node;
return DECL_BIT_FIELD_TYPE(Field) ?
DECL_BIT_FIELD_TYPE(Field) : TREE_TYPE (Field);
}
@@ -135,9 +135,9 @@
}
if (Name) {
- if (TREE_CODE(Name) == IDENTIFIER_NODE) {
+ if (isa<IDENTIFIER_NODE>(Name)) {
return IDENTIFIER_POINTER(Name);
- } else if (TREE_CODE(Name) == TYPE_DECL && DECL_NAME(Name) &&
+ } else if (isa<TYPE_DECL>(Name) && DECL_NAME(Name) &&
!DECL_IGNORED_P(Name)) {
return StringRef(IDENTIFIER_POINTER(DECL_NAME(Name)));
}
@@ -343,7 +343,7 @@
DIType Ty = getOrCreateType(Node);
return DIDescriptor(Ty);
} else if (DECL_P (Node)) {
- if (TREE_CODE (Node) == NAMESPACE_DECL) {
+ if (isa<NAMESPACE_DECL>(Node)) {
DIDescriptor NSContext = findRegion(DECL_CONTEXT(Node));
DINameSpace NS = getOrCreateNameSpace(Node, NSContext);
return DIDescriptor(NS);
@@ -383,7 +383,7 @@
// Construct variable.
DIScope VarScope = DIScope(cast<MDNode>(RegionStack.back()));
DIType Ty = getOrCreateType(type);
- if (!Ty && TREE_CODE(type) == OFFSET_TYPE)
+ if (!Ty && isa<OFFSET_TYPE>(type))
Ty = createPointerType(TREE_TYPE(type));
if (Ty && DECL_ARTIFICIAL (decl))
Ty = DebugFactory.CreateArtificialType(Ty);
@@ -437,7 +437,7 @@
StringRef LinkageName;
// The gdb does not expect linkage names for function local statics.
if (DECL_CONTEXT (decl))
- if (TREE_CODE (DECL_CONTEXT (decl)) != FUNCTION_DECL)
+ if (!isa<FUNCTION_DECL>(DECL_CONTEXT (decl)))
LinkageName = GV->getName();
DebugFactory.CreateGlobalVariable(findRegion(DECL_CONTEXT(decl)),
DispName, DispName, LinkageName,
@@ -472,7 +472,7 @@
Encoding = DW_ATE_float;
break;
case COMPLEX_TYPE:
- Encoding = TREE_CODE(TREE_TYPE(type)) == REAL_TYPE ?
+ Encoding = isa<REAL_TYPE>(TREE_TYPE(type)) ?
DW_ATE_complex_float : DW_ATE_lo_user;
break;
case BOOLEAN_TYPE:
@@ -498,8 +498,8 @@
/// isArtificialArgumentType - Return true if arg_type represents artificial,
/// i.e. "this" in c++, argument.
static bool isArtificialArgumentType(tree arg_type, tree method_type) {
- if (TREE_CODE (method_type) != METHOD_TYPE) return false;
- if (TREE_CODE (arg_type) != POINTER_TYPE) return false;
+ if (!isa<METHOD_TYPE>(method_type)) return false;
+ if (!isa<POINTER_TYPE>(arg_type)) return false;
if (TREE_TYPE (arg_type) == TYPE_METHOD_BASETYPE (method_type))
return true;
if (main_type (arg_type) && main_type (arg_type) != TREE_TYPE (arg_type)
@@ -570,13 +570,13 @@
DIType FromTy = getOrCreateType(TREE_TYPE(type));
// type* and type&
// FIXME: Should BLOCK_POINTER_TYP have its own DW_TAG?
- unsigned Tag = TREE_CODE(type) == REFERENCE_TYPE ?
+ unsigned Tag = isa<REFERENCE_TYPE>(type) ?
DW_TAG_reference_type: DW_TAG_pointer_type;
unsigned Flags = 0;
// Check if this pointer type has a name.
if (tree TyName = TYPE_NAME(type))
- if (TREE_CODE(TyName) == TYPE_DECL && !DECL_ORIGINAL_TYPE(TyName)) {
+ if (isa<TYPE_DECL>(TyName) && !DECL_ORIGINAL_TYPE(TyName)) {
expanded_location TypeNameLoc = GetNodeLocation(TyName);
DIType Ty =
DebugFactory.CreateDerivedType(Tag, findRegion(DECL_CONTEXT(TyName)),
@@ -611,8 +611,8 @@
DIType DebugInfo::createArrayType(tree type) {
// type[n][m]...[p]
- if (TREE_CODE (type) == ARRAY_TYPE
- && TYPE_STRING_FLAG(type) && TREE_CODE(TREE_TYPE(type)) == INTEGER_TYPE){
+ if (isa<ARRAY_TYPE>(type)
+ && TYPE_STRING_FLAG(type) && isa<INTEGER_TYPE>(TREE_TYPE(type))) {
DEBUGASSERT(0 && "Don't support pascal strings");
return DIType();
}
@@ -625,9 +625,9 @@
// There will be ARRAY_TYPE nodes for each rank. Followed by the derived
// type.
tree EltTy = TREE_TYPE(type);
- if (TREE_CODE(type) == ARRAY_TYPE) {
+ if (isa<ARRAY_TYPE>(type)) {
tree atype = type;
- for (; TREE_CODE(atype) == ARRAY_TYPE; atype = TREE_TYPE(atype)) {
+ for (; isa<ARRAY_TYPE>(atype); atype = TREE_TYPE(atype)) {
tree Domain = TYPE_DOMAIN(atype);
if (Domain) {
// FIXME - handle dynamic ranges
@@ -644,7 +644,7 @@
EltTy = TREE_TYPE(atype);
}
} else {
- assert(TREE_CODE(type) == VECTOR_TYPE && "Not an array or vector type!");
+ assert(isa<VECTOR_TYPE>(type) && "Not an array or vector type!");
unsigned Length = TYPE_VECTOR_SUBPARTS(type);
Subscripts.push_back(DebugFactory.GetOrCreateSubrange(0, Length));
}
@@ -670,7 +670,7 @@
if (TYPE_SIZE(type)) {
for (tree Link = TYPE_VALUES(type); Link; Link = TREE_CHAIN(Link)) {
tree EnumValue = TREE_VALUE(Link);
- if (TREE_CODE(EnumValue) == CONST_DECL)
+ if (isa<CONST_DECL>(EnumValue))
EnumValue = DECL_INITIAL(EnumValue);
int64_t Value = getInt64(EnumValue, false);
const char *EnumName = IDENTIFIER_POINTER(TREE_PURPOSE(Link));
@@ -700,7 +700,7 @@
DIType DebugInfo::createStructType(tree type) {
// struct { a; b; ... z; }; | union { a; b; ... z; };
- unsigned Tag = TREE_CODE(type) == RECORD_TYPE ? DW_TAG_structure_type :
+ unsigned Tag = isa<RECORD_TYPE>(type) ? DW_TAG_structure_type :
DW_TAG_union_type;
unsigned RunTimeLang = 0;
@@ -817,7 +817,7 @@
// Get the location of the member.
expanded_location MemLoc = GetNodeLocation(Member, false);
- if (TREE_CODE(Member) != FIELD_DECL)
+ if (!isa<FIELD_DECL>(Member))
// otherwise is a static variable, whose debug info is emitted
// when through EmitGlobalVariable().
continue;
@@ -829,8 +829,8 @@
/* Ignore nameless fields. */
if (DECL_NAME (Member) == NULL_TREE
- && !(TREE_CODE (TREE_TYPE (Member)) == UNION_TYPE
- || TREE_CODE (TREE_TYPE (Member)) == RECORD_TYPE))
+ && !(isa<UNION_TYPE>(TREE_TYPE(Member)) ||
+ isa<RECORD_TYPE>(TREE_TYPE(Member))))
continue;
// Field type is the declared type of the field.
@@ -934,7 +934,7 @@
if (I != TypeCache.end())
if (I->second)
return DIType(cast<MDNode>(I->second));
- if (TREE_CODE(TyDef) == TYPE_DECL && DECL_ORIGINAL_TYPE(TyDef)) {
+ if (isa<TYPE_DECL>(TyDef) && DECL_ORIGINAL_TYPE(TyDef)) {
expanded_location TypeDefLoc = GetNodeLocation(TyDef);
Ty = DebugFactory.CreateDerivedType(DW_TAG_typedef,
findRegion(DECL_CONTEXT(TyDef)),
@@ -995,7 +995,7 @@
// Should only be void if a pointer/reference/return type. Returning NULL
// allows the caller to produce a non-derived type.
- if (TREE_CODE(type) == VOID_TYPE) return DIType();
+ if (isa<VOID_TYPE>(type)) return DIType();
// Check to see if the compile unit already has created this type.
std::map<tree_node *, WeakVH >::iterator I = TypeCache.find(type);
Modified: dragonegg/trunk/src/DefaultABI.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/DefaultABI.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/DefaultABI.cpp (original)
+++ dragonegg/trunk/src/DefaultABI.cpp Fri Apr 13 15:48:54 2012
@@ -37,6 +37,9 @@
#include "tree.h"
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
void DefaultABIClient::anchor() {}
// doNotUseShadowReturn - Return true if the specified GCC type
@@ -45,7 +48,7 @@
(void)CC; // Not used by all ABI macros.
if (!TYPE_SIZE(type))
return false;
- if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST)
+ if (!isa<INTEGER_CST>(TYPE_SIZE(type)))
return false;
// LLVM says do not use shadow argument.
if (LLVM_SHOULD_NOT_RETURN_COMPLEX_IN_MEMORY(type) ||
@@ -66,7 +69,7 @@
tree isSingleElementStructOrArray(tree type, bool ignoreZeroLength,
bool rejectFatBitfield) {
// Complex numbers have two fields.
- if (TREE_CODE(type) == COMPLEX_TYPE) return 0;
+ if (isa<COMPLEX_TYPE>(type)) return 0;
// All other scalars are good.
if (!AGGREGATE_TYPE_P(type)) return type;
@@ -79,20 +82,19 @@
return 0;
case RECORD_TYPE:
// If this record has variable length, reject it.
- if (TREE_CODE(TYPE_SIZE(type)) != INTEGER_CST)
+ if (!isa<INTEGER_CST>(TYPE_SIZE(type)))
return 0;
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
- if (TREE_CODE(Field) == FIELD_DECL) {
+ if (isa<FIELD_DECL>(Field)) {
if (ignoreZeroLength) {
- if (DECL_SIZE(Field) &&
- TREE_CODE(DECL_SIZE(Field)) == INTEGER_CST &&
+ if (DECL_SIZE(Field) && isa<INTEGER_CST>(DECL_SIZE(Field)) &&
TREE_INT_CST_LOW(DECL_SIZE(Field)) == 0)
continue;
}
if (!FoundField) {
if (rejectFatBitfield &&
- TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST &&
+ isa<INTEGER_CST>(TYPE_SIZE(type)) &&
TREE_INT_CST_LOW(TYPE_SIZE(TREE_TYPE(Field))) >
TREE_INT_CST_LOW(TYPE_SIZE(type)))
return 0;
@@ -115,9 +117,9 @@
/// isZeroSizedStructOrUnion - Returns true if this is a struct or union
/// which is zero bits wide.
bool isZeroSizedStructOrUnion(tree type) {
- if (TREE_CODE(type) != RECORD_TYPE &&
- TREE_CODE(type) != UNION_TYPE &&
- TREE_CODE(type) != QUAL_UNION_TYPE)
+ if (!isa<RECORD_TYPE>(type) &&
+ !isa<UNION_TYPE>(type) &&
+ !isa<QUAL_UNION_TYPE>(type))
return false;
return int_size_in_bytes(type) == 0;
}
@@ -151,7 +153,7 @@
} else if (doNotUseShadowReturn(type, fn, C.getCallingConv())) {
tree SingleElt = LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(type);
if (SingleElt && TYPE_SIZE(SingleElt) &&
- TREE_CODE(TYPE_SIZE(SingleElt)) == INTEGER_CST &&
+ isa<INTEGER_CST>(TYPE_SIZE(SingleElt)) &&
TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) ==
TREE_INT_CST_LOW(TYPE_SIZE_UNIT(SingleElt))) {
C.HandleAggregateResultAsScalar(ConvertType(SingleElt));
@@ -252,9 +254,9 @@
} else if (isZeroSizedStructOrUnion(type)) {
// Zero sized struct or union, just drop it!
;
- } else if (TREE_CODE(type) == RECORD_TYPE) {
+ } else if (isa<RECORD_TYPE>(type)) {
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
- if (TREE_CODE(Field) == FIELD_DECL) {
+ if (isa<FIELD_DECL>(Field)) {
const tree Ftype = TREE_TYPE(Field);
unsigned FNo = GetFieldIndex(Field, Ty);
assert(FNo < INT_MAX && "Case not handled yet!");
@@ -273,17 +275,17 @@
C.ExitField();
}
}
- } else if (TREE_CODE(type) == COMPLEX_TYPE) {
+ } else if (isa<COMPLEX_TYPE>(type)) {
C.EnterField(0, Ty);
HandleArgument(TREE_TYPE(type), ScalarElts);
C.ExitField();
C.EnterField(1, Ty);
HandleArgument(TREE_TYPE(type), ScalarElts);
C.ExitField();
- } else if ((TREE_CODE(type) == UNION_TYPE) ||
- (TREE_CODE(type) == QUAL_UNION_TYPE)) {
+ } else if ((isa<UNION_TYPE>(type)) ||
+ (isa<QUAL_UNION_TYPE>(type))) {
HandleUnion(type, ScalarElts);
- } else if (TREE_CODE(type) == ARRAY_TYPE) {
+ } else if (isa<ARRAY_TYPE>(type)) {
// Array with padding?
if (Ty->isStructTy())
Ty = cast<StructType>(Ty)->getTypeAtIndex(0U);
@@ -303,7 +305,7 @@
if (TYPE_TRANSPARENT_AGGR(type)) {
tree Field = TYPE_FIELDS(type);
assert(Field && "Transparent union must have some elements!");
- while (TREE_CODE(Field) != FIELD_DECL) {
+ while (!isa<FIELD_DECL>(Field)) {
Field = TREE_CHAIN(Field);
assert(Field && "Transparent union must have some elements!");
}
@@ -314,9 +316,9 @@
unsigned MaxSize = 0;
tree MaxElt = 0;
for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) {
- if (TREE_CODE(Field) == FIELD_DECL) {
+ if (isa<FIELD_DECL>(Field)) {
// Skip fields that are known not to be present.
- if (TREE_CODE(type) == QUAL_UNION_TYPE &&
+ if (isa<QUAL_UNION_TYPE>(type) &&
integer_zerop(DECL_QUALIFIER(Field)))
continue;
@@ -328,7 +330,7 @@
}
// Skip remaining fields if this one is known to be present.
- if (TREE_CODE(type) == QUAL_UNION_TYPE &&
+ if (isa<QUAL_UNION_TYPE>(type) &&
integer_onep(DECL_QUALIFIER(Field)))
break;
}
Modified: dragonegg/trunk/src/Trees.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Trees.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/Trees.cpp (original)
+++ dragonegg/trunk/src/Trees.cpp Fri Apr 13 15:48:54 2012
@@ -62,7 +62,7 @@
// Name identifier nodes after their contents. This gives the desired effect
// when called recursively.
- if (TREE_CODE(t) == IDENTIFIER_NODE)
+ if (isa<IDENTIFIER_NODE>(t))
return std::string(IDENTIFIER_POINTER(t), IDENTIFIER_LENGTH(t));
// Handle declarations of all kinds.
@@ -72,15 +72,15 @@
return std::string(IDENTIFIER_POINTER(DECL_NAME(t)),
IDENTIFIER_LENGTH(DECL_NAME(t)));
// Use a generic name for function results.
- if (TREE_CODE(t) == RESULT_DECL)
+ if (isa<RESULT_DECL>(t))
return "<retval>";
// Labels have their own numeric unique identifiers.
- if (TREE_CODE(t) == LABEL_DECL && LABEL_DECL_UID(t) != -1) {
+ if (isa<LABEL_DECL>(t) && LABEL_DECL_UID(t) != -1) {
Twine LUID(LABEL_DECL_UID(t));
return ("L" + LUID).str();
}
// Otherwise use the generic UID.
- const char *Annotation = TREE_CODE(t) == CONST_DECL ? "C." : "D.";
+ const char *Annotation = isa<CONST_DECL>(t) ? "C." : "D.";
Twine UID(DECL_UID(t));
return (Annotation + UID).str();
}
@@ -91,29 +91,29 @@
const std::string &TypeName = getDescriptiveName(TYPE_NAME(t));
if (!TypeName.empty()) {
// Annotate the name with a description of the type's class.
- if (TREE_CODE(t) == ENUMERAL_TYPE)
+ if (isa<ENUMERAL_TYPE>(t))
return "enum." + TypeName;
- if (TREE_CODE(t) == RECORD_TYPE)
+ if (isa<RECORD_TYPE>(t))
return "struct." + TypeName;
- if (TREE_CODE(t) == QUAL_UNION_TYPE)
+ if (isa<QUAL_UNION_TYPE>(t))
return "qualunion." + TypeName;
- if (TREE_CODE(t) == UNION_TYPE)
+ if (isa<UNION_TYPE>(t))
return "union." + TypeName;
return TypeName;
}
// Try to deduce a useful name.
- if (TREE_CODE(t) == ARRAY_TYPE)
+ if (isa<ARRAY_TYPE>(t))
// If the element type is E, name the array E[] (regardless of the number
// of dimensions).
return concatIfNotEmpty(getDescriptiveName(TREE_TYPE(t)), "[]");
- if (TREE_CODE(t) == COMPLEX_TYPE)
+ if (isa<COMPLEX_TYPE>(t))
// If the element type is E, name the complex number complex.E.
return concatIfNotEmpty("complex.", getDescriptiveName(TREE_TYPE(t)));
- if (TREE_CODE(t) == POINTER_TYPE)
+ if (isa<POINTER_TYPE>(t))
// If the element type is E, name the pointer E*.
return concatIfNotEmpty(getDescriptiveName(TREE_TYPE(t)), "*");
- if (TREE_CODE(t) == REFERENCE_TYPE)
+ if (isa<REFERENCE_TYPE>(t))
// If the element type is E, name the reference E&.
return concatIfNotEmpty(getDescriptiveName(TREE_TYPE(t)), "&");
@@ -121,7 +121,7 @@
}
// Handle SSA names.
- if (TREE_CODE(t) == SSA_NAME) {
+ if (isa<SSA_NAME>(t)) {
Twine NameVersion(SSA_NAME_VERSION(t));
return concatIfNotEmpty(getDescriptiveName(SSA_NAME_VAR(t)),
("_" + NameVersion).str());
@@ -133,7 +133,7 @@
/// getIntegerValue - Return the specified INTEGER_CST as an APInt.
APInt getIntegerValue(const_tree exp) {
- assert(TREE_CODE(exp) == INTEGER_CST && "Expected an integer constant!");
+ assert(isa<INTEGER_CST>(exp) && "Expected an integer constant!");
double_int val = tree_to_double_int(exp);
unsigned NumBits = TYPE_PRECISION(TREE_TYPE(exp));
@@ -159,7 +159,7 @@
assert(HOST_BITS_PER_WIDE_INT == 32 &&
"Only 32- and 64-bit hosts supported!");
return
- (TREE_CODE (t) == INTEGER_CST && !TREE_OVERFLOW (t))
+ (isa<INTEGER_CST>(t) && !TREE_OVERFLOW (t))
&& ((TYPE_UNSIGNED(TREE_TYPE(t)) == Unsigned) ||
// If the constant is signed and we want an unsigned result, check
// that the value is non-negative. If the constant is unsigned and
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Fri Apr 13 15:48:54 2012
@@ -79,7 +79,7 @@
public:
/// Dereference operator.
tree operator*() {
- return TREE_CODE(type_ref) == TREE_LIST ?
+ return isa<TREE_LIST>(type_ref) ?
TREE_VALUE(type_ref) : TREE_TYPE(type_ref);
};
@@ -197,7 +197,7 @@
/// ArrayLengthOf - Returns the length of the given gcc array type, or NO_LENGTH
/// if the array has variable or unknown length.
uint64_t ArrayLengthOf(tree type) {
- assert(TREE_CODE(type) == ARRAY_TYPE && "Only for array types!");
+ assert(isa<ARRAY_TYPE>(type) && "Only for array types!");
// Workaround for missing sanity checks in older versions of GCC.
if ((GCC_MINOR == 5 && GCC_MICRO < 3) || (GCC_MINOR == 6 && GCC_MICRO < 2))
if (!TYPE_DOMAIN(type) || !TYPE_MAX_VALUE(TYPE_DOMAIN(type)))
@@ -233,7 +233,7 @@
/// that its first bit is within the byte the LLVM field starts at). Returns
/// INT_MAX if there is no such LLVM field.
int GetFieldIndex(tree decl, Type *Ty) {
- assert(TREE_CODE(decl) == FIELD_DECL && "Expected a FIELD_DECL!");
+ assert(isa<FIELD_DECL>(decl) && "Expected a FIELD_DECL!");
// FIXME: The following test sometimes fails when compiling Fortran90 because
// DECL_CONTEXT does not point to the containing type, but some other type!
// assert(Ty == ConvertType(DECL_CONTEXT(decl)) && "Field not for this type!");
@@ -316,7 +316,7 @@
/// that this returns false for function types, for which the GCC type size
/// doesn't represent anything useful for us.
static bool isSized(tree type) {
- if (TREE_CODE(type) == FUNCTION_TYPE || TREE_CODE(type) == METHOD_TYPE)
+ if (isa<FUNCTION_TYPE>(type) || isa<METHOD_TYPE>(type))
return false;
return TYPE_SIZE(type);
}
@@ -403,7 +403,7 @@
// FIXME: Search for TREE_ADDRESSABLE in calls.c, and see if there are other
// cases that make arguments automatically passed in by reference.
return TREE_ADDRESSABLE(Type) || TYPE_SIZE(Type) == 0 ||
- TREE_CODE(TYPE_SIZE(Type)) != INTEGER_CST;
+ !isa<INTEGER_CST>(TYPE_SIZE(Type));
}
@@ -426,7 +426,7 @@
// NOTE: Any changes made here need to be reflected in LoadRegisterFromMemory,
// StoreRegisterToMemory and ExtractRegisterFromConstant.
assert(!AGGREGATE_TYPE_P(type) && "Registers must have a scalar type!");
- assert(TREE_CODE(type) != VOID_TYPE && "Registers cannot have void type!");
+ assert(!isa<VOID_TYPE>(type) && "Registers cannot have void type!");
switch (TREE_CODE(type)) {
@@ -632,10 +632,10 @@
}
static Attributes HandleArgumentExtension(tree ArgTy) {
- if (TREE_CODE(ArgTy) == BOOLEAN_TYPE) {
+ if (isa<BOOLEAN_TYPE>(ArgTy)) {
if (TREE_INT_CST_LOW(TYPE_SIZE(ArgTy)) < INT_TYPE_SIZE)
return Attribute::ZExt;
- } else if (TREE_CODE(ArgTy) == INTEGER_TYPE &&
+ } else if (isa<INTEGER_TYPE>(ArgTy) &&
TREE_INT_CST_LOW(TYPE_SIZE(ArgTy)) < INT_TYPE_SIZE) {
if (TYPE_UNSIGNED(ArgTy))
return Attribute::ZExt;
@@ -934,14 +934,13 @@
// Drill down through nested arrays to the ultimate element type. Thanks
// to this we may return S* for a (S[])*, which is better than {}*.
- while (TREE_CODE(pointee) == ARRAY_TYPE)
+ while (isa<ARRAY_TYPE>(pointee))
pointee = main_type(pointee);
// If the pointee is a record or union type then return a pointer to its
// placeholder type. Otherwise return {}*.
- if (TREE_CODE(pointee) == QUAL_UNION_TYPE ||
- TREE_CODE(pointee) == RECORD_TYPE ||
- TREE_CODE(pointee) == UNION_TYPE)
+ if (isa<QUAL_UNION_TYPE>(pointee) || isa<RECORD_TYPE>(pointee) ||
+ isa<UNION_TYPE>(pointee))
PointeeTy = getCachedType(pointee);
else
PointeeTy = StructType::get(Context);
@@ -1089,14 +1088,13 @@
// Record all interesting fields so they can easily be visited backwards.
SmallVector<tree, 16> Fields;
for (tree field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
- assert(TREE_CODE(field) == FIELD_DECL && "Lang data not freed?");
+ assert(isa<FIELD_DECL>(field) && "Lang data not freed?");
// Ignore fields with variable or unknown position since they cannot be
// represented by the LLVM type system.
if (!OffsetIsLLVMCompatible(field))
continue;
// Skip fields that are known not to be present.
- if (TREE_CODE(type) == QUAL_UNION_TYPE &&
- integer_zerop(DECL_QUALIFIER(field)))
+ if (isa<QUAL_UNION_TYPE>(type) && integer_zerop(DECL_QUALIFIER(field)))
continue;
Fields.push_back(field);
}
@@ -1568,9 +1566,9 @@
// the nasty {}* type we are obliged to return in general.
for (size_t i = 0, e = SCC.size(); i != e; ++i) {
tree some_type = SCC[i];
- if (TREE_CODE(some_type) != QUAL_UNION_TYPE &&
- TREE_CODE(some_type) != RECORD_TYPE &&
- TREE_CODE(some_type) != UNION_TYPE) {
+ if (!isa<QUAL_UNION_TYPE>(some_type) &&
+ !isa<RECORD_TYPE>(some_type) &&
+ !isa<UNION_TYPE>(some_type)) {
assert(!getCachedType(some_type) && "Type already converted!");
continue;
}
Modified: dragonegg/trunk/src/arm/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/arm/Target.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/arm/Target.cpp (original)
+++ dragonegg/trunk/src/arm/Target.cpp Fri Apr 13 15:48:54 2012
@@ -46,6 +46,9 @@
#include "toplev.h"
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
static LLVMContext &Context = getGlobalContext();
// "Fundamental Data Types" according to the AAPCS spec. These are used
@@ -105,7 +108,7 @@
}
// And now merge the fields of structure.
for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) {
- if (TREE_CODE (field) == FIELD_DECL) {
+ if (isa<FIELD_DECL>(field)) {
if (TREE_TYPE (field) == error_mark_node)
continue;
@@ -148,7 +151,7 @@
for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) {
int union_field_fdt_counts[ARM_FDT_MAX] = { 0 };
- if (TREE_CODE (field) == FIELD_DECL) {
+ if (isa<FIELD_DECL>(field)) {
if (TREE_TYPE (field) == error_mark_node)
continue;
Modified: dragonegg/trunk/src/x86/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/x86/Target.cpp?rev=154702&r1=154701&r2=154702&view=diff
==============================================================================
--- dragonegg/trunk/src/x86/Target.cpp (original)
+++ dragonegg/trunk/src/x86/Target.cpp Fri Apr 13 15:48:54 2012
@@ -45,6 +45,9 @@
#include "toplev.h"
}
+// Trees header.
+#include "dragonegg/Trees.h"
+
static LLVMContext &Context = getGlobalContext();
/// BitCastToIntVector - Bitcast the vector operand to a vector of integers of
@@ -1004,7 +1007,7 @@
/* It returns true if an aggregate of the specified type should be passed as a
first class aggregate. */
bool llvm_x86_should_pass_aggregate_as_fca(tree type, Type *Ty) {
- if (TREE_CODE(type) != COMPLEX_TYPE)
+ if (!isa<COMPLEX_TYPE>(type))
return false;
StructType *STy = dyn_cast<StructType>(Ty);
if (!STy || STy->isPacked()) return false;
@@ -1257,9 +1260,9 @@
bool llvm_x86_should_pass_vector_in_integer_regs(tree type) {
if (!TARGET_MACHO)
return false;
- if (TREE_CODE(type) == VECTOR_TYPE &&
+ if (isa<VECTOR_TYPE>(type) &&
TYPE_SIZE(type) &&
- TREE_CODE(TYPE_SIZE(type))==INTEGER_CST) {
+ isa<INTEGER_CST>(TYPE_SIZE(type))) {
if (TREE_INT_CST_LOW(TYPE_SIZE(type))==64 && TARGET_MMX)
return false;
if (TREE_INT_CST_LOW(TYPE_SIZE(type))==128 && TARGET_SSE)
@@ -1277,9 +1280,9 @@
return false;
if (!TARGET_64BIT)
return false;
- if (TREE_CODE(type) == VECTOR_TYPE &&
+ if (isa<VECTOR_TYPE>(type) &&
TYPE_SIZE(type) &&
- TREE_CODE(TYPE_SIZE(type))==INTEGER_CST) {
+ isa<INTEGER_CST>(TYPE_SIZE(type))) {
if (TREE_INT_CST_LOW(TYPE_SIZE(type))<=128)
return false;
}
@@ -1295,9 +1298,9 @@
tree llvm_x86_should_return_vector_as_scalar(tree type, bool isBuiltin) {
if (TARGET_MACHO &&
!isBuiltin &&
- TREE_CODE(type) == VECTOR_TYPE &&
+ isa<VECTOR_TYPE>(type) &&
TYPE_SIZE(type) &&
- TREE_CODE(TYPE_SIZE(type))==INTEGER_CST) {
+ isa<INTEGER_CST>(TYPE_SIZE(type))) {
if (TREE_INT_CST_LOW(TYPE_SIZE(type))==64 &&
TYPE_VECTOR_SUBPARTS(type)==1)
return uint64_type_node;
@@ -1317,9 +1320,9 @@
tree retType = isSingleElementStructOrArray(type, true, false);
if (!retType || !TARGET_64BIT || !TARGET_MACHO)
return retType;
- if (TREE_CODE(retType) == VECTOR_TYPE &&
+ if (isa<VECTOR_TYPE>(retType) &&
TYPE_SIZE(retType) &&
- TREE_CODE(TYPE_SIZE(retType))==INTEGER_CST &&
+ isa<INTEGER_CST>(TYPE_SIZE(retType)) &&
TREE_INT_CST_LOW(TYPE_SIZE(retType))==64)
return double_type_node;
return retType;
@@ -1331,9 +1334,9 @@
if (TARGET_MACHO &&
!isBuiltin &&
!TARGET_64BIT &&
- TREE_CODE(type) == VECTOR_TYPE &&
+ isa<VECTOR_TYPE>(type) &&
TYPE_SIZE(type) &&
- TREE_CODE(TYPE_SIZE(type))==INTEGER_CST) {
+ isa<INTEGER_CST>(TYPE_SIZE(type))) {
if (TREE_INT_CST_LOW(TYPE_SIZE(type))==64 &&
TYPE_VECTOR_SUBPARTS(type)>1)
return true;
@@ -1350,7 +1353,7 @@
if (!TARGET_64BIT)
return false;
- if (TREE_CODE(type) == COMPLEX_TYPE &&
+ if (isa<COMPLEX_TYPE>(type) &&
TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) == 32)
return true;
More information about the llvm-commits
mailing list