similar to: [LLVMdev] How to cast Value* to ConstantDataArray*

Displaying 20 results from an estimated 500 matches similar to: "[LLVMdev] How to cast Value* to ConstantDataArray*"

2013 Apr 20
0
[LLVMdev] How to cast Value* to ConstantDataArray*
On Sat, Apr 20, 2013 at 5:15 PM, Richard Catlin <richard.m.catlin at gmail.com>wrote: > I extended the LLVM Kaleidoscope example to support Strings. I added a > StringExprAST, which has the virtual Codegen method impl as follows: > > Value *StringExprAST::Codegen() { > StringRef r(Val); > return ConstantDataArray::getString(getGlobalContext(), r, false); > } >
2013 Apr 21
2
[LLVMdev] How to cast Value* to ConstantDataArray*
ConstantDataArray * cda = cast<ConstantDataArray>(v); throws this error: Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Users/rcatlin1/lldb/llvm/include/llvm/Support/Casting.h, line 208 Thanks for the help. Richard Catlin On Sat, Apr 20, 2013 at 3:37 PM, Sean Silva <silvas at purdue.edu> wrote:
2012 Nov 16
2
[LLVMdev] porting to 3.1: ConstantDataArray
Hi, In llvm 3.0 llvm::ConstantArray had a ::getAsCString() method that returned the buffer as a std::string. Now it seems that 3.1 this method dissapeared. I found that llvm::ConstantDataArray has a method called getAsString(), but it returns a Constant*. What is the safe way to retrieve the pointer of the Constant array as a C string?
2012 Nov 16
0
[LLVMdev] porting to 3.1: ConstantDataArray
On 16 November 2012 13:55, charles quarra <charllsnotieneningunputocorreo at gmail.com> wrote: > In llvm 3.0 llvm::ConstantArray had a ::getAsCString() method that > returned the buffer as a std::string. Now it seems that 3.1 this > method dissapeared. > > I found that llvm::ConstantDataArray has a method called > getAsString(), but it returns a Constant*. In 3.1
2013 Mar 26
0
[LLVMdev] Fwd: Extending Kaleidoscope to support Strings
I hope this is the right place to ask this question. If not, please let me know where I can ask for help. We are using Kaleidoscope as the base framework to write a source to source compiler. Our source language has Strings with supported operations such as concatenation, upper case, and substrings. I am following the patterns set forth in Kaleidoscope, and need to represent my std::string as
2015 May 28
1
[LLVMdev] Passing ConstantDataArray to GetElementPtrInst
Hi, I'm having a hard time finding an answer to what I assume is a very basic idea. I'm trying to produce this llvm code using the LLVM api: %myString = alloca [13 x i8], i32 13 store [13 x i8] c"Hello world.\00", [13 x i8]* %myString %tmp1 = getelementptr [13 x i8]* %myString, i32 0, i32 0 %tmp2 = call i32 (i8*, ...)* @printf( i8* %tmp1 ) nounwind A simple Hello
2016 Aug 24
2
Change GlobalValue Type/Initializer
Hi, I am trying to update the initializer of a global value and I have encounter two issues: The first one is that I can not change the type of the global value. Let say that I have the following variable: @.str = private unnamed_addr constant [6 x i8] c”Test0A\00", align 1 How can I change the ”Test0A\00” to ”OtherTest0A\00”. Is this possible? I know that you can change the initializer
2016 Aug 24
2
Change GlobalValue Type/Initializer
Hi Mehdi, Thank you for you answer. > Yes it is normal you *have* to use the same context to manipulate IR inside a Module. The context owns the module and destroying the context destroys everything that is created in the context. It is not clear to me what other context you could even manage to use here conceptually. Actually I was using llvm::getGlobalContext() in order to get the context.
2012 Sep 05
1
[LLVMdev] Calling a function with a pointer to a global char array as argument
Hello; Thanks to Eli for the pointer to the ConstantDataArray::getString() fucntion. Now I am trying to declare a global char array with the content "hi" and call a function "print" (which takes a char pointer and return an insteger. I am doing the following in the code - Function Creation: PointerType* array = PointerType::get(IntegerType::getInt8Ty(getGlobalContext())
2012 May 09
1
[LLVMdev] 3.1 API Breakage
On Tue, May 8, 2012 at 7:16 PM, Albert Graef <Dr.Graef at t-online.de> wrote: > Now I've run into another issue: The ConstantArray::get() method for > constructing a string  constant from a char* seems to be gone. Is there > a replacement for that somewhere? ConstantDataArray::getString. IRBuilder::CreateGlobalString might also be useful in some cases. > BTW, this isn't
2013 Jun 25
2
[LLVMdev] get value
Hello ! This may be a trivial question, but I cannot get fields from a Value type. If my Value is i32 1, how can I store 1 in a different structure (an integer) ? For the type, I have getType(). For the value, I see no method in Value.h. I tried to cast to ConstantExpr and then to get operands, or cast to ConstantDataArray and then use getAsString(), but is not working. How should I get the
2017 Apr 08
2
Getting a pointer to a i8 from a global variable that holds a constant string
Hello, I'm trying to get the pointer to the first element of a string (so that I can pass it to a function). The string itself is a constant kept in a global variable. My end goal is to generate the IR for something like "puts("Hello World")"; I'm stuck on the parameter part of the call instruction. So far I have something like this: const std::string& str =
2013 Jun 25
4
[LLVMdev] get value
Hi Cristianno, Thank you, it works :) with an extra cast:                                     Value *v ......                                     ConstantInt* RR = (ConstantInt *)v;                                     uint64_t VV = (RR->getValue()).getLimitedValue();                                     errs()<<"\nRR  "<<VV<<"\n";
2017 Sep 10
2
Performance of large llvm::ConstantDataArrays
On Sat, Sep 9, 2017 at 10:18 PM, Chris Lattner via llvm-dev < llvm-dev at lists.llvm.org> wrote: > > On Sep 7, 2017, at 11:06 PM, Chris Lovett via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > I'm running into some pretty bad performance in llc.exe when compiling > some large neural networks into code that contains some very large llvm::ConstantDataArrays,
2012 Dec 19
2
[LLVMdev] GetElementPtrConstantExpr
Ok, now it's arising another problem. IR code that I obtain is the following: i8* bitcast ([5 x i8] c"hello\00" to i8*) generated from instructions: ConstantExpr::getBitCast (ConstantDataArray::getString (getGlobalContext (), "hello"), PointerType::get (Type::getInt8Ty (getGlobalContext ()), 0)) but the LLC tool says: invalid cast opcode for cast from '[5 x i8]'
2020 Oct 01
3
Creating a global variable for a struct array
>The type you pass to GlobalVariable's constructor for that variable should be "[10 x %struct.dlist]" because that's what you want storage for. Then the GlobalVariable itself will be a Constant of type "[10 x %struct.dlist]*". Yes, I verified that this is the case. I enabled assertions and the error seems to occur while creating GlobalVariable for both struct dhash
2013 Jun 25
0
[LLVMdev] get value
Hi Alexandru, if you have a Value pointer named v, you could use the method v->getValue(). getLimitedValue(), which returns uint64_t, that can be casted as int. Hope I could help, -- Cristianno Martins PhD Student of Computer Science University of Campinas cmartins at ic.unicamp.br <cristiannomartins at hotmail.com> On Tue, Jun 25, 2013 at 4:05 AM, Alexandru Ionut Diaconescu <
2013 Jun 25
0
[LLVMdev] get value
Oops, that's true: I forgot about that XD sorry =) Glad I could help, -- Cristianno Martins PhD Student of Computer Science University of Campinas cmartins at ic.unicamp.br <cristiannomartins at hotmail.com> On Tue, Jun 25, 2013 at 4:38 AM, Alexandru Ionut Diaconescu < cyrusthevirus001x at yahoo.com> wrote: > Hi Cristianno, > > Thank you, it works :) > > with
2013 Jun 26
0
[LLVMdev] get value
Alexandru Ionut Diaconescu wrote: > Hi Cristianno, > > Thank you, it works :) > > with an extra cast: > Value *v ...... > ConstantInt* RR = (ConstantInt *)v; Please use "cast<ConstantInt>(v)" instead. See http://llvm.org/docs/ProgrammersManual.html#the-isa-cast-and-dyn-cast-templates . Nick > uint64_t VV = (RR->getValue()).getLimitedValue(); >
2012 Dec 19
0
[LLVMdev] GetElementPtrConstantExpr
On 19/12/12 10:25, Alessio Giovanni Baroni wrote: > Ok, now it's arising another problem. IR code that I obtain is the following: > > i8* bitcast ([5 x i8] c"hello\00" to i8*) You need to put your "hello" in a (constant) global variable. You can then bitcast the address of the global to i8*. I suggest you compile some C code that makes use of the address of a