Add build from llvm

This commit is contained in:
Colin 2021-12-17 13:29:59 +00:00
parent 911f65874f
commit be63e84a1d
3 changed files with 21 additions and 5 deletions

View File

@ -1,5 +1,7 @@
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
ABI = -mabi=ilp32 -march=rv32imc
@ -9,10 +11,10 @@ target = default
# Allow tool override
VERILATOR = verilator
GCC_PREFIX = /opt/riscv/bin/riscv64-unknown-elf
TESTDIR = ${PWD}
BUILD_DIR = ${TESTDIR}/build
SWERV_CONFIG = ${TESTDIR}/swerv.config
RV_DESIGN = ${RV_ROOT}/design
TEST = hello_world
@ -81,8 +83,11 @@ program.hex: $(OFILES) $(LINK)
$(GCC_PREFIX)-cpp -I${BUILD_DIR} $< > $(BUILD_DIR)/$*.cpp.s
$(GCC_PREFIX)-as $(ABI) $(BUILD_DIR)/$*.cpp.s -o $(BUILD_DIR)/$@
##################### llvm hex Build #####################################
%.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:
@echo Possible targets: verilator help clean all verilator-build program.hex

View File

@ -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;
}

View File

@ -76,6 +76,6 @@ _finish:
.data
hw_data:
.ascii "----------------------------------\n"
.ascii "Hello World from Colin EH1 @WDC !!\n"
.ascii "Hello World Colin.liang EH1@WDC !!\n"
.ascii "----------------------------------\n"
.byte 0