Add build from llvm
This commit is contained in:
parent
911f65874f
commit
be63e84a1d
|
@ -1,5 +1,7 @@
|
||||||
export RV_ROOT = ${PWD}/../..
|
export RV_ROOT = ${PWD}/../..
|
||||||
RV_DESIGN = ${RV_ROOT}/design
|
LLVMINSTALL = /home/colin/develop/llvm-build/install
|
||||||
|
GCC_PREFIX = /opt/riscv/bin/riscv64-unknown-elf
|
||||||
|
|
||||||
|
|
||||||
TEST_CFLAGS = -g -O3 -funroll-all-loops
|
TEST_CFLAGS = -g -O3 -funroll-all-loops
|
||||||
ABI = -mabi=ilp32 -march=rv32imc
|
ABI = -mabi=ilp32 -march=rv32imc
|
||||||
|
@ -9,10 +11,10 @@ target = default
|
||||||
|
|
||||||
# Allow tool override
|
# Allow tool override
|
||||||
VERILATOR = verilator
|
VERILATOR = verilator
|
||||||
GCC_PREFIX = /opt/riscv/bin/riscv64-unknown-elf
|
|
||||||
TESTDIR = ${PWD}
|
TESTDIR = ${PWD}
|
||||||
BUILD_DIR = ${TESTDIR}/build
|
BUILD_DIR = ${TESTDIR}/build
|
||||||
SWERV_CONFIG = ${TESTDIR}/swerv.config
|
SWERV_CONFIG = ${TESTDIR}/swerv.config
|
||||||
|
RV_DESIGN = ${RV_ROOT}/design
|
||||||
|
|
||||||
TEST = hello_world
|
TEST = hello_world
|
||||||
|
|
||||||
|
@ -81,10 +83,13 @@ program.hex: $(OFILES) $(LINK)
|
||||||
$(GCC_PREFIX)-cpp -I${BUILD_DIR} $< > $(BUILD_DIR)/$*.cpp.s
|
$(GCC_PREFIX)-cpp -I${BUILD_DIR} $< > $(BUILD_DIR)/$*.cpp.s
|
||||||
$(GCC_PREFIX)-as $(ABI) $(BUILD_DIR)/$*.cpp.s -o $(BUILD_DIR)/$@
|
$(GCC_PREFIX)-as $(ABI) $(BUILD_DIR)/$*.cpp.s -o $(BUILD_DIR)/$@
|
||||||
|
|
||||||
|
##################### llvm hex Build #####################################
|
||||||
|
|
||||||
%.o : %.c ${BUILD_DIR}/defines.h
|
%.o : %.c ${BUILD_DIR}/defines.h
|
||||||
$(GCC_PREFIX)-gcc -I${BUILD_DIR} ${TEST_CFLAGS} ${ABI} -nostdlib -c $< -o $(BUILD_DIR)/$@
|
$(LLVMINSTALL)/bin/clang --target=riscv32 -march=rv32gc $*.c -c -o $(BUILD_DIR)/$*.o -mno-relax
|
||||||
|
$(LLVMINSTALL)/bin/ld.lld $(BUILD_DIR)/$*.o -o $(BUILD_DIR)/$*
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo Possible targets: verilator help clean all verilator-build program.hex
|
@echo Possible targets: verilator help clean all verilator-build program.hex
|
||||||
|
|
||||||
.PHONY: help clean verilator
|
.PHONY: help clean verilator
|
|
@ -0,0 +1,11 @@
|
||||||
|
// #include <stdio.h>
|
||||||
|
|
||||||
|
int add (int a,int b){
|
||||||
|
return a+b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
//printf("Hello RISCV!\n");
|
||||||
|
int a = add(1,23);
|
||||||
|
return a;
|
||||||
|
}
|
|
@ -76,6 +76,6 @@ _finish:
|
||||||
.data
|
.data
|
||||||
hw_data:
|
hw_data:
|
||||||
.ascii "----------------------------------\n"
|
.ascii "----------------------------------\n"
|
||||||
.ascii "Hello World from Colin EH1 @WDC !!\n"
|
.ascii "Hello World Colin.liang EH1@WDC !!\n"
|
||||||
.ascii "----------------------------------\n"
|
.ascii "----------------------------------\n"
|
||||||
.byte 0
|
.byte 0
|
||||||
|
|
Loading…
Reference in New Issue