打印LLVM::Type或者LLVM::Value的值
2017-01-09 10:34
1216 查看
#include "llvm/ADT/STLExtras.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Support/Casting.h" #include "llvm/Support/raw_ostream.h" #include <memory> #include "iostream" using namespace llvm; /// Returns the string representation of a llvm::Value* or llvm::Type* template <typename T> static std::string Print(T* value_or_type) { std::string str; llvm::raw_string_ostream stream(str); value_or_type->print(stream); return str; } int main() { LLVMContext Context; // Create some module to put our function into it. std::unique_ptr<Module> Owner = make_unique<Module>("test", Context); Module *mod = Owner.get(); /* //param numBits the bit width of the constructed APInt //param str the string to be interpreted //param radix the radix to use for the conversion APInt(unsigned numBits, StringRef str, uint8_t radix); //ConstantInt int type constant */ ConstantInt* const_int32_one = ConstantInt::get(mod->getContext(), APInt(32, StringRef("1"), 10)); std::string result = Print(const_int32_one); std::cout << result << std::endl; return 0; }
相关文章推荐
- Could not cast value of type 'Swift._SwiftDeferredNSDictionary'或者'Swift._SwiftDeferredNSArray' ?
- <input type="submit" value="打印" onClick="javascrip
- [SharePoint]javascript client object model 获取lookup 类型的field的值,包括user类型(单人或者多人)的值。how to get the multiple user type/lookup type field value by Javascript client object model
- [llvm] LLVM 核心类简明示例 : llvm::Value && llvm::Type && llvm::Constant
- value_type, key_type, mapped_type, reference,const_reference
- zabbix value type导致的断图一例 推荐
- weblogic部署异常: cvc-enumeration-valid: string value '3.0' is not a valid enumeration value for web-app-versionType in namespace http://java.sun.com/xml/ns/javaee:<null>
- 正确检查上传文件类型或者get mine type from file
- Android错误:W/ResourceType(2411): No package identifier when getting value for resource number 0x
- Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching e
- 170524、java.lang.IllegalArgumentException: No converter found for return value of type异常解决
- js下读取或者设置input中的value值
- keil(MDK)中出现error: #513: a value of type "int" cannot be assigned to an entity of type "char *",即函数返回值无法赋值给对应变量的错误
- flink出现could not find implicit value for evidence parameter of type org.apache.flink.api.com
- JS获取jQuery获取当前<input type="text" />的value--通过测试了
- ls:Value too large for defined data type 解决办法
- Value and type
- nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframewo
- Failed to convert property value of type [org.apache.commons.dbcp.BasicDataSource] to required
- The method getValue(String) from the type HttpSession is deprecated