Apply patches from PR136

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10192 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Brian Gaeke
2003-11-24 02:57:25 +00:00
parent 866f10c493
commit 3e4a271c89
7 changed files with 178 additions and 44 deletions

View File

@ -14,34 +14,46 @@ LEVEL = ../../..
#
DIRS =
TESTS = fibonacci hello prime
SAMPLES = fibonacci hello prime
all :: $(TESTS)
all :: $(SAMPLES)
ifdef OPTIMIZE
%.bc : %.st
stkrc -e -o - $< | opt -stats -q -f -o $*.bc \
@$(ECHO) "Compiling and Optimizing $< to $*.bc"
$(VERB)stkrc -e -o - $< | opt -stats -q -f -o $*.bc \
-aa-eval -adce -branch-combine -cee -constmerge -constprop -dce -die -ds-aa \
-ds-opt -gcse -globaldce -indvars -inline -instcombine \
-ipconstprop -licm -loopsimplify -mem2reg -pre -sccp -simplifycfg \
-tailcallelim -verify
else
%.bc : %.st
stkrc -e -f -o $*.bc $<
@$(ECHO) "Compiling $< to $*.bc"
$(VERB)stkrc -e -f -o $*.bc $<
endif
%.s : %.bc
llc -f -o $*.s $<
@$(ECHO) "Compiling $< to $*.s"
$(VERB)llc -f -o $*.s $<
% : %.s
gcc -g -L$(BUILD_OBJ_ROOT)/lib/Debug -lstkr_runtime -o $* $*.s
@$(ECHO) "Compiling and Linking $< to $*"
$(VERB)gcc -g -L$(BUILD_OBJ_ROOT)/lib/Debug -lstkr_runtime -o $* $*.s
%.ll : %.bc
llvm-dis -f -o $*.ll $<
@$(ECHO) "Disassembling $< to $*.ll"
$(VERB)llvm-dis -f -o $*.ll $<
%.bc : $(BUILD_OBJ_ROOT)/tools/Debug/stkrc
.PRECIOUS: %.bc %.s %.ll %.st
SAMPLES_LL = $(SAMPLES:%=%.ll)
SAMPLES_BC = $(SAMPLES:%=%.bc)
SAMPLES_S = $(SAMPLES:%=%.s)
clean ::
$(VERB)rm -f gmon.out $(SAMPLES_LL) $(SAMPLES_BC) $(SAMPLES_S) $(SAMPLES)
#
# Include the Master Makefile that knows how to build all.
#

View File

@ -1 +1,25 @@
: defmebaby 23 0 = ;
#
# goof
#
: print_one
--
SWAP
>s
DROP
;
: print_it
WHILE
print_one
END
;
: MAIN
"MICKEY: I said she was f'in goofy!"
"MICKEY: I didn't say she was insane."
"JUDGE: Yet you provide no evidence of this and I do not concur."
"JUDGE: In your pleadings you claim that Mini Mouse is insane."
"MICKEY: Well, what do you mean, your honor?"
"JUDGE: Mr. Mouse, I find your grounds for divorce insufficient. "
6
print_it
;

View File

@ -139,7 +139,7 @@
################################################################################
: consider_prime
DUP ( save the prime number to consider )
10000 < IF ( check to see if we are done yet )
1000000 < IF ( check to see if we are done yet )
done ( we are done, call "done" )
ENDIF
++ ( increment to next prime number )
@ -157,6 +157,8 @@
# STACK>: empty
################################################################################
: find_primes
"Prime Numbers: " >s CR ( say hello )
DROP ( get rid of that pesky string )
1 ( stoke the fires )
print ( print the first one, we know its prime )
WHILE ( loop while the prime to consider is non zero )
@ -165,12 +167,69 @@
;
################################################################################
# The MAIN program just prints a banner and calls find_primes.
# STACK<: empty
# STACK>: empty
#
################################################################################
: say_yes
>d ( Print the prime number )
" is prime." ( push string to output )
>s ( output it )
CR ( print carriage return )
DROP ( pop string )
;
: say_no
>d ( Print the prime number )
" is NOT prime." ( push string to put out )
>s ( put out the string )
CR ( print carriage return )
DROP ( pop string )
;
################################################################################
# This definition processes a single command line argument and determines if it
# is a prime number or not.
# STACK<:
# n - number of arguments
# arg1 - the prime numbers to examine
# STACK>:
# n-1 - one less than number of arguments
# arg2 - we processed one argument
################################################################################
: do_one_argument
-- ( decrement loop counter )
SWAP ( get the argument value )
is_prime IF ( determine if its prime )
say_yes ( uhuh )
ELSE
say_no ( nope )
ENDIF
DROP ( done with that argument )
;
################################################################################
# The MAIN program just prints a banner and processes its arguments.
# STACK<:
# n - number of arguments
# ... - the arguments
################################################################################
: process_arguments
WHILE ( while there are more arguments )
do_one_argument ( process one argument )
END
;
################################################################################
# The MAIN program just prints a banner and processes its arguments.
# STACK<: arguments
################################################################################
: MAIN
"Prime Numbers: " >s CR ( say hello )
DROP ( get rid of that pesky string )
find_primes ( see how many we can find )
NIP ( get rid of the program name )
-- ( reduce number of arguments )
DUP ( save the arg counter )
1 <= IF ( See if we got an argument )
process_arguments ( tell user if they are prime )
ELSE
find_primes ( see how many we can find )
ENDIF
0 ( push return code )
;