[LLVMdev] New backend help request.
James Boulton
eiconic at googlemail.com
Wed Jul 8 09:40:20 PDT 2015
Hi all,
I'm trying to continue an existing m68k backend for LLVM. I'm completely new
to LLVM development so I've been muddling my way through mostly by trial and
error and using existing back ends for reference. I'm trying to implement
code to allow calling. I am compiling this C code --
typedef unsigned int uint32_t;
typedef char int8_t;
uint32_t foo(uint32_t x, int8_t y)
{
return (x | (1 << 17)) + y;
}
int main()
{
uint32_t b = foo(10,12);
}
And getting the following error from LLVM --
# Machine code for function main: Post SSA
Frame Objects:
fi#0: size=4, align=4, at location [SP]
Function Live Outs: %D0L
BB#0: derived from LLVM BB %entry
ADJCALLSTACKDOWN 6, %A7<imp-def>, %A7<imp-use>
%vreg2<def> = COPY %A7; DR32:%vreg2
%vreg1<def> = COPY %vreg2; AR:%vreg1 DR32:%vreg2
MOVElim %vreg1<kill>, 0, 10; mem:ST4[<unknown>](align=2) AR:%vreg1
%vreg2<def,tied1> = ADDlqd %vreg2<tied0>, 4, %CCR<imp-def,dead>;
DR32:%vreg2
%vreg3<def> = COPY %vreg2; AR:%vreg3 DR32:%vreg2
MOVEbim %vreg3<kill>, 0, 12; mem:ST1[<unknown>] AR:%vreg3
CALL <ga:@foo>, %A7<imp-use>, ...
ADJCALLSTACKUP 6, 0, %A7<imp-def>, %A7<imp-use>
%vreg4<def> = COPY %D0L; DR32:%vreg4
MOVEldm <fi#0>, 0, %vreg4<kill>; mem:ST4[%b] DR32:%vreg4
%vreg5<def> = MOVEQ 0; DR32:%vreg5
%D0L<def> = COPY %vreg5<kill>; DR32:%vreg5
RTS %D0L<imp-use,kill>
# End machine code for function main.
*** Bad machine code: Using an undefined physical register ***
- function: main
- basic block: BB#0 entry (0xa19eac)
- instruction: %vreg4<def> = COPY %D0L; DR32:%vreg4
- operand 1: %D0L
LLVM ERROR: Found 1 machine code errors.
Stack dump:
0. Program arguments:
D:\RetroMods\Jaguar\Compiler\llvm-build\bin\Debug\llc
.exe -mtriple m68k-apple-mac test.ll
1. Running pass 'Function Pass Manager' on module 'test.ll'.
2. Running pass 'Greedy Register Allocator' on function '@main'
To me this looks like the result from the call (D0) is not being set
somewhere to let LLVM know the register is available when it tries to copy
it into the virtual register. I'm using the MSP430 target as reference, and
I'm doing everything this target is, so I'm not sure what I'm missing.
Any tips would be most appreciated.
More information about the llvm-dev
mailing list