本文整理汇总了C++中llvm::Module::getTypeName方法的典型用法代码示例。如果您正苦于以下问题:C++ Module::getTypeName方法的具体用法?C++ Module::getTypeName怎么用?C++ Module::getTypeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::Module
的用法示例。
在下文中一共展示了Module::getTypeName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_type_declaration
void Aa::write_type_declaration(llvm::Type *T, llvm::Module& tst)
{
std::string type_name = to_aa(tst.getTypeName(T));
if(type_name == "")
return;
if(!T->isStructTy())
return;
std::cout << "$record [" << type_name << "] ";
const llvm::StructType *ptr_struct = dyn_cast<llvm::StructType>(T);
for(int idx = 0; idx < ptr_struct->getNumElements(); idx++)
{
std::cout << "< " ;
std::cout << get_aa_type_name(ptr_struct->getElementType(idx),tst);
std::cout << " > ";
}
std::cout << std::endl;
}
示例2: get_aa_type_name
std::string Aa::get_aa_type_name(const llvm::Type* ptr, llvm::Module& tst)
{
if(ptr->isVoidTy())
return("$void");
std::string ret_string = tst.getTypeName(ptr);
if(ret_string != "")
return(to_aa(ret_string));
if(isa<PointerType>(ptr))
{
ret_string = "$pointer< ";
const llvm::PointerType *ptr_pointer = dyn_cast<llvm::PointerType>(ptr);
const llvm::Type* el_type = ptr_pointer->getElementType();
ret_string += get_aa_type_name(el_type,tst);
ret_string += " >";
}
else if(isa<ArrayType>(ptr) || isa<VectorType>(ptr))
{
const llvm::SequentialType *ptr_seq = dyn_cast<llvm::SequentialType>(ptr);
const llvm::Type* el_type = ptr_seq->getElementType();
int dim = 0;
const llvm::ArrayType* ptr_array = dyn_cast<llvm::ArrayType>(ptr);
if(ptr_array != NULL)
dim = ptr_array->getNumElements();
else
{
const llvm::VectorType* ptr_vec = dyn_cast<llvm::VectorType>(ptr);
dim = ptr_vec->getNumElements();
}
ret_string = "$array [" + int_to_str(dim) + "] $of ";
ret_string += get_aa_type_name(el_type,tst);
}
else if(isa<StructType>(ptr))
{
const llvm::StructType *ptr_struct = dyn_cast<llvm::StructType>(ptr);
ret_string = "$record ";
for(int idx = 0; idx < ptr_struct->getNumElements(); idx++)
{
ret_string += "< " ;
ret_string += get_aa_type_name(ptr_struct->getElementType(idx),tst);
ret_string += " > ";
}
}
else if(isa<IntegerType>(ptr))
{
ret_string = "$uint<";
const llvm::IntegerType* ptr_int = dyn_cast<llvm::IntegerType>(ptr);
ret_string += int_to_str(ptr_int->getBitWidth()) + ">";
}
else if(ptr->isFloatTy())
{
ret_string = "$float<8,23>";
}
else if(ptr->isDoubleTy())
{
ret_string = "$float<11,52>";
}
else if(ptr->isVoidTy())
{
ret_string = "$void";
}
else if(ptr->isFunctionTy())
{
std::cerr << "Warning: function type converted to void*" << std::endl;
ret_string = "$pointer < $void > ";
}
else
{
std::cerr << "Error: unsupported type" << std::endl;
ret_string = "Unsupported_Type";
}
return(ret_string);
}