All Questions
158 questions
1
vote
1
answer
60
views
Correct immediate range of ldr in apple arm, possible clang assmbler bug
Running clang-as on this code produces "error: index must be an integer in range [-256, 255]"
.section __TEXT,__text,regular,pure_instructions
.p2align 2
_foo:
...
0
votes
0
answers
54
views
Why the order of Assembly code changed after Machine Code Sinking?
I am new to compiler and llvm, and I am sorry if my question or approach is kinda odd...
Following is the example machine code:
bb.0.entry:
successors: %bb.1(0x50000000), %bb.5(0x30000000); %bb.1(62....
0
votes
0
answers
42
views
How to instruct Clang to populate offset based on Fixed Segment Addresses in AArch64 assembly?
I'm working on an aarch64 code analysis project where I need to use clang to convert aarch64 assembly code into bytecode, and then use llvm-objdump to extract and analyze the bytecode. Additionally, I ...
1
vote
1
answer
828
views
LLVM IR: ".s" file vs ".ll" file vs ".bc" file
I read that the '.ll' file is equivalent to the '.bc' file except that '.ll' is more human readable. But is '.ll' machine independent? I see references to x86_64 in my '.ll' file. In my '.s' file I ...
-1
votes
1
answer
158
views
"junk at end of line" when assembling .s file compiled from C++ file using Clang and LLVM, but works with C file
I am learning how to use the LLVM toolchain. I have a .cpp file, and I'm trying to compile it to an LLVM bitcode file, compile the LLVM bytecode file into an assembly file, and then assemble the ...
1
vote
0
answers
76
views
LLVM code generation causes problems with pointer arithmetic
I'm attempting to write my own Operating System using my own language (compiler built using LLVM), but my code causes a page fault. This is the LLVM IR code generated by my compiler:
define i32 @...
1
vote
0
answers
155
views
How to convert LLVM IR file (*.ll) to riscv64 assembly code? llc -march=riscv64 failed
I am new to LLVM, but I have some difficulties.
How can I convert LLVM IR file to riscv64 assembly code?
I'm in x86 platform, using ubuntu 22.04,
I try to use ./llc -march=riscv64 test.ll
but it give ...
3
votes
1
answer
81
views
How to insert a JNE instruction (jump not equal) using buildmi in LLVM x86 machine function pass
I'm writing an LLVM machine function pass that need to insert some instructions at the start of each basic block. What those instructions do is that it load a value from a place and compare it with a ...
0
votes
0
answers
113
views
Is there any way to use inline assembly or any other way to use assembly on unsupported architecture in Rust language?
The title is probably too long...
I'm new to embed Rust. And I'm writing a program involves the usage of assembly in Rust.
I saw Rust by Example, which says:
Inline assembly is currently supported on ...
1
vote
0
answers
120
views
SelectionDag To Machine Instruction in LLVM?
The scheduling phase takes the DAG of target instructions from the selection phase and assigns an order. The scheduler can pick an order depending on various constraints of the machines (i.e. order ...
0
votes
1
answer
996
views
How to build a bare metal app for aarch64 using LLVM?
I am trying to understand how I can compile and link a bare metal app using LLVM (macOS).
loader.s:
.global _reset
_reset:
# Set up stack pointer
LDR X2, =stack_top
MOV SP, X2
# Magic ...
0
votes
0
answers
237
views
Compiling assembly (.s file) using gcc error c++ standard library
I am trying to compile an .s file I produced using llvm (llc) back to an .exe file.
When trying to compile the .s file using g++ with g++ output.s -o test.exe, I get multiple errors of
output.s:344: ...
1
vote
0
answers
47
views
is there a way to store arm64 assembly code in module using LLVM API?
I'm currently working on a compiler project using llvm.
I have IR Module , But I want function which takes IR module as argument and return Assembly module of TARGET(ARM64 or aarch64).
.My goal is to ...
5
votes
1
answer
225
views
LLVM, Expected Instruction?
I wrote the following short Assembly LLVM code (I know it's not efficent only for testing purposes):
define void @main() {
label_41:
%t22 = add i32 0, 0
label_43:
%t23 = add i32 0, 0
}
When I try to ...
0
votes
1
answer
381
views
LLVM, Why we need `load` and `store`?
I was reading: https://llvm.org/docs/LangRef.html#getelementptr-instruction
From what I can understand LLVM has infinite registers which raises the question, why we need store and load commands at all ...