[LLVMdev] add Inline assembly in LLVM IR

Jian-Ru Chen jrchen at sslab5.cs.nctu.edu.tw
Fri Jun 7 03:18:24 PDT 2013


Hi all,
I'm working for translating dex bytecode to LLVM IR
In order to communicate with Android interpreter,
The work have to add data below some instructions

I want to use inline assembly to add data.
Thus, I wrote a little program to find out the related LLVM IR

int main()
{
    asm(".long 0x12345678");
    return 0;
}

and I use clang to translate it into bitcode
It's the result...

; ModuleID = 'hello.c'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i32 @main() nounwind uwtable {
entry:
  %retval = alloca i32, align 4
  store i32 0, i32* %retval
  call void asm sideeffect ".long 0x12345678",
"~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
  ret i32 0
}

!0 = metadata !{i32 20}

--
And I want to know which LLVM API should I use to generate "  call void asm
sideeffect ".long 0x12345678", "~{dirflag},~{fpsr},~{flags}"() nounwind,
!srcloc !0" ?

Thanks!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130607/683e408f/attachment.html>


More information about the llvm-dev mailing list