add Inline assembly in LLVM IR

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

add Inline assembly in LLVM IR

Jian-Ru Chen-2
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!!

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: add Inline assembly in LLVM IR

Duncan Sands
Hi Jian-Ru Chen, if you run llc on your bitcode with -march=cpp then it should
output the series of API calls needed to produce that bitcode.

Ciao, Duncan.

On 07/06/13 12:18, Jian-Ru Chen wrote:

> 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!!
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: add Inline assembly in LLVM IR

Jian-Ru Chen
Thanks for your help!
It's a helpful information!!