Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. if [[ $1 == "--help" ]]; then
  4. echo "Usage: compile-test <source>"
  5. echo "Utility for small evm backend test cases. Takes a C source file, compiles it to llvm IR, and runs the backend."
  6. echo "All data, including the source file, llvm IR, output, and logs are moved to a directory of the same name for ease of organization."
  7. echo "IMPORTANT: a symlink to the correct llc must be present in the current directory. Please make one, or this will fail silently."
  8. exit 0
  9. fi
  10.  
  11. if [[ $# -ne 1 ]]; then
  12. echo "incorrect number of arguments" >&2; exit 1
  13. fi
  14.  
  15. IR_OUT="$1.ll"
  16. EVM_OUT="$1.out"
  17. TEST_DIR="test-$1"
  18.  
  19. echo "test directory: $TEST_DIR"
  20.  
  21. mkdir ./$TEST_DIR
  22.  
  23. clang --version
  24. ./llc --version
  25.  
  26. # Generate IR
  27. clang -S -emit-llvm $1 -o $TEST_DIR/$IR_OUT
  28.  
  29. if [[ $? -ne 0 ]]; then
  30. echo "clang failed; exiting" >&2
  31. rm -rf $TEST_DIR; exit 1
  32. fi
  33.  
  34. echo "wrote clang output to $TEST_DIR/$IR_OUT"
  35. echo "calling evm backend..."
  36.  
  37. ./llc -mtriple=evm -debug $TEST_DIR/$IR_OUT -o $TEST_DIR/$EVM_OUT 2>$TEST_DIR/log.txt
  38.  
  39. if [[ $? -ne 0 ]]; then
  40. echo "backend failed. refer to $TEST_DIR/backendlog.txt if present."; exit 1
  41. fi
  42.  
  43. mv $1 $TEST_DIR/$1
  44.  
  45. echo "backend succeeded; moved source to test dir"
  46. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement