简体   繁体   English

在LLVM中将ConstantDataArray转换为i8 *

[英]Cast ConstantDataArray to i8* in LLVM

Simple question: "I have a ConstantDataArray of type [7 x i8] , how can I cast it to have the i8* type?" 一个简单的问题:“我有一个[7 x i8]类型的ConstantDataArray,如何将其转换为i8*类型?”

EDIT More Context: 编辑更多上下文:

The ConstantDataArray is created as follows: ConstantDataArray创建如下:

ConstantDataArray::getString(Fn->getContext(), "Hello", true);

And I have created a LLVM:Function that has an argument with the type coming from Type::getInt8PtrTy(getGlobalContext()) and I want to cast the array to this type, so I can pass it as an argument. 而且我创建了一个LLVM:Function,该函数具有一个类型为Type::getInt8PtrTy(getGlobalContext())并且我想将数组转换为该类型,因此可以将其作为参数传递。

I'm developing a pass 我正在开发通行证

您可以使用IRBuilderCreateGlobalStringPtr ,它是用于创建全局字符串常量并返回指向其第一个字符的i8*的便捷包装器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM