mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Folded inssel*.ll into select.ll.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@621 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
|
default: testcodegen
|
||||||
|
|
||||||
LLC := ../tools/Debug/llc
|
LLC := ../tools/Debug/llc
|
||||||
AS := ../tools/Debug/as
|
AS := ../tools/Debug/as
|
||||||
LLCOPTS := -dsched t
|
LLCOPTS := -dsched y
|
||||||
|
|
||||||
TESTS := $(wildcard *.ll)
|
TESTS := $(wildcard *.ll)
|
||||||
|
|
||||||
LLCTESTS := $(shell /bin/ls *.ll | grep -v testmemory | grep -v testswitch | grep -v sumarray | grep -v globalvars)
|
LLCTESTS := $(shell /bin/ls *.ll | grep -v testmemory | grep -v testswitch | grep -v sumarray )
|
||||||
|
|
||||||
|
|
||||||
test all : testasmdis testopt testcodegen
|
test all : testasmdis testopt testcodegen
|
||||||
@@ -37,5 +39,5 @@ clean :
|
|||||||
|
|
||||||
%.mc: %.ll $(LLC) $(AS)
|
%.mc: %.ll $(LLC) $(AS)
|
||||||
@echo "Generating machine instructions for $<"
|
@echo "Generating machine instructions for $<"
|
||||||
$(AS) < $< | $(LLC) -dsched=t > $@
|
$(AS) < $< | $(LLC) $(LLCOPTS) > $@
|
||||||
|
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
implementation
|
|
||||||
|
|
||||||
void "foo"(int * %x, int * %y)
|
|
||||||
begin
|
|
||||||
; <label>:0 ;[#uses=0]
|
|
||||||
seteq int * %x, %y ; <bool>:0 [#uses=0]
|
|
||||||
ret void
|
|
||||||
end
|
|
@@ -1,14 +0,0 @@
|
|||||||
implementation
|
|
||||||
|
|
||||||
void "foo"(int * %x, int * %y)
|
|
||||||
begin
|
|
||||||
; <label>:0 ;[#uses=1]
|
|
||||||
br label %Top
|
|
||||||
|
|
||||||
Top: ;[#uses=4]
|
|
||||||
phi int [ 0, %0 ], [ 1, %Top ], [ 2, %Next ] ; <int>:0 [#uses=0]
|
|
||||||
br bool true, label %Top, label %Next
|
|
||||||
|
|
||||||
Next: ;[#uses=2]
|
|
||||||
br label %Top
|
|
||||||
end
|
|
30
test/sched.ll
Normal file
30
test/sched.ll
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
implementation
|
||||||
|
declare int "printf"(sbyte*, int, float)
|
||||||
|
|
||||||
|
|
||||||
|
int "testissue"(int %i, float %x, float %y)
|
||||||
|
begin
|
||||||
|
bb1:
|
||||||
|
%x1 = mul float %x, %y ;; x1
|
||||||
|
%y1 = mul float %y, 0.75 ;; y1
|
||||||
|
%z1 = add float %x1, %y1 ;; z1 = x1 + y1
|
||||||
|
|
||||||
|
%x2 = mul float %x, 0.5 ;; x2
|
||||||
|
%y2 = mul float %y, 0.9 ;; y2
|
||||||
|
%z2 = add float %x2, %y2 ;; z2 = x2 + y2
|
||||||
|
|
||||||
|
%z3 = add float %z1, %z2 ;; z3 = z1 + z2
|
||||||
|
|
||||||
|
%i1 = shl int %i, ubyte 3 ;; i1
|
||||||
|
%j1 = add int %i, 7 ;; j1
|
||||||
|
%m1 = add int %i1, %j1 ;; k1 = i1 + j1
|
||||||
|
;; %m1 = div int %k1, 99 ;; m1 = k1 / 99
|
||||||
|
|
||||||
|
%b = setle int %m1, 6 ;; (m1 <= 6)?
|
||||||
|
br bool %b, label %bb1, label %bb2
|
||||||
|
|
||||||
|
bb2:
|
||||||
|
%Msg = cast ulong 0 to sbyte *
|
||||||
|
call int (sbyte*, int, float) %printf(sbyte* %Msg, int %m1, float %z3)
|
||||||
|
ret int 0
|
||||||
|
end
|
93
test/select.ll
Normal file
93
test/select.ll
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
implementation
|
||||||
|
|
||||||
|
; A SetCC whose result is used should produce instructions to
|
||||||
|
; compute the boolean value in a register. One whose result
|
||||||
|
; is unused will only generate the condition code but not
|
||||||
|
; the boolean result.
|
||||||
|
;
|
||||||
|
void "unusedBool"(int * %x, int * %y)
|
||||||
|
begin
|
||||||
|
; <label>:0 ; [#uses=0]
|
||||||
|
seteq int * %x, %y ; <bool>:0 [#uses=1]
|
||||||
|
not bool %0 ; <bool>:1 [#uses=0]
|
||||||
|
setne int * %x, %y ; <bool>:2 [#uses=0]
|
||||||
|
ret void
|
||||||
|
end
|
||||||
|
|
||||||
|
; A constant argument to a Phi produces a Cast instruction in the
|
||||||
|
; corresponding predecessor basic block. This has little to do with
|
||||||
|
; selection but the code is a bit weird.
|
||||||
|
;
|
||||||
|
void "mergeConstants"(int * %x, int * %y)
|
||||||
|
begin
|
||||||
|
; <label>:0 ; [#uses=1]
|
||||||
|
br label %Top
|
||||||
|
Top: ; [#uses=4]
|
||||||
|
phi int [ 0, %0 ], [ 1, %Top ], [ 2, %Next ] ; <int>:0 [#uses=0]
|
||||||
|
br bool true, label %Top, label %Next
|
||||||
|
Next: ; [#uses=2]
|
||||||
|
br label %Top
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
; Test branch-on-comparison-with-zero, in two ways:
|
||||||
|
; 1. can be folded
|
||||||
|
; 2. cannot be folded because result of comparison is used twice
|
||||||
|
;
|
||||||
|
void "testbool"(int, int) ; Def %0, %1
|
||||||
|
int 0 ; Def 2
|
||||||
|
int -4 ; Def 3
|
||||||
|
begin
|
||||||
|
add int %0, %1 ; Def 4
|
||||||
|
sub int %4, %3 ; Def 5
|
||||||
|
setle int %5, %2 ; Def 0 - bool plane
|
||||||
|
br bool %0, label %retlbl, label %loop
|
||||||
|
|
||||||
|
loop:
|
||||||
|
add int %0, %1 ; Def 6
|
||||||
|
sub int %4, %3 ; Def 7
|
||||||
|
setle int %7, %2 ; Def 1 - bool
|
||||||
|
not bool %1 ; Def 2 - bool. first use of bool %1
|
||||||
|
br bool %1, label %loop, label %0 ; second use of bool %1
|
||||||
|
|
||||||
|
retlbl:
|
||||||
|
ret void
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
; Test branch on floating point comparison
|
||||||
|
;
|
||||||
|
void "testfloatbool"(float %x, float %y) ; Def %0, %1 - float
|
||||||
|
begin
|
||||||
|
%p = add float %x, %y ; Def 2 - float
|
||||||
|
%z = sub float %x, %y ; Def 3 - float
|
||||||
|
%b = setle float %p, %z ; Def 0 - bool
|
||||||
|
%c = not bool %b ; Def 1 - bool
|
||||||
|
br bool %b, label %0, label %goon
|
||||||
|
goon:
|
||||||
|
ret void
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
; Test cases where an LLVM instruction requires no machine
|
||||||
|
; instructions (e.g., cast int* to long). But there are 2 cases:
|
||||||
|
; 1. If the result register has only a single use, the operand will be
|
||||||
|
; copy-propagated during instruction selection.
|
||||||
|
; 2. If the result register has multiple uses, it cannot be copy
|
||||||
|
; propagated during instruction selection. It will generate a
|
||||||
|
; copy instruction (add-with-0), but this copy should get coalesced
|
||||||
|
; away by the register allocator.
|
||||||
|
;
|
||||||
|
int "checkForward"(int %N, int* %A)
|
||||||
|
begin
|
||||||
|
|
||||||
|
bb2: ;;<label>
|
||||||
|
%reg114 = shl int %N, ubyte 2 ;;
|
||||||
|
%cast115 = cast int %reg114 to int* ;; reg114 will be propagated
|
||||||
|
%reg116 = add int* %A, %cast115 ;;
|
||||||
|
%reg118 = load int* %reg116 ;;
|
||||||
|
%cast117 = cast int %reg118 to long ;; reg118 will be copied 'cos
|
||||||
|
%reg159 = add long 1234567, %cast117 ;; cast117 has 2 uses, here
|
||||||
|
%reg160 = add long 7654321, %cast117 ;; and here.
|
||||||
|
ret void
|
||||||
|
end
|
Reference in New Issue
Block a user