blob: dbb0f5f007c6599406647c74f318d284c809c2d5 [file] [log] [blame]
Andrey Churbanova951e212015-04-29 14:36:38 +00001#!/bin/bash
2
3# add header for .ll files
4
5# get tmp header
6cp header /tmp/tmp.header
7echo >> /tmp/tmp.header
8
9# create temporary test package
10mkdir c-$MACHTYPE$OSTYPE
11`cp c/*.ll c-$MACHTYPE$OSTYPE/`
12
13# add new header into .ll files
14for file in c-$MACHTYPE$OSTYPE/*
15do
16 cp $file /tmp/tmp.ll.bf
17 cat /tmp/tmp.header /tmp/tmp.ll.bf > /tmp/tmp.ll
18 mv /tmp/tmp.ll $file
19done
20
21
22# in bin/, target is ../LLVM-IR/ARCH/OS
23LEVEL=../LLVM-IR/
24ARCH_PATH=../LLVM-IR/
25OS_PATH=../LLVM-IR/
26
27# for linux system, add your arch and os here
28declare -a ARCHes=(x86 x86_64 powerpc arm mips darwin)
29declare -a OSes=(linux macosx windows darwin)
30
31declare lowerARCH
32declare lowerOS
33
34# target directory name
35declare upperARCH
36declare upperOS
37
38lowerARCH=$(echo "$MACHTYPE" | tr '[:upper:]' '[:lower:]')
39lowerOS=$(echo "$OSTYPE" | tr '[:upper:]' '[:lower:]')
40
41# ARCH
42for i in ${ARCHes[@]}
43do
44 result=$(echo "${lowerARCH}" | grep $i)
45 if [[ "$result" != "" ]]
46 then
47 # upperARCH=$i
48 upperARCH=$(echo "$i" | tr '[:lower:]' '[:upper:]')
49 fi
50done
51
52if [[ "$upperARCH" == "" ]]
53then
54 echo "Not found ${lowerARCH} in the [${ARCHes[@]}]!"
55 exit
56fi
57
58# OS
59for i in ${OSes[@]}
60do
61 result=$(echo "${lowerOS}" | grep $i)
62 if [[ "$result" != "" ]]
63 then
64 # upperOS=$i
65 upperOS=$(echo "$i" | tr '[:lower:]' '[:upper:]')
66 fi
67done
68
69if [[ "$upperOS" == "" ]]
70then
71 echo "Not found ${lowerOS} in the [${OSes[@]}]!"
72 exit
73fi
74
75# survived, assemble the path
76# ARCH_PATH+=$upperARCH/
77# OS_PATH+=$upperARCH/$upperOS/
78ARCH_newFormat=.
79if [ $upperARCH = "X86" ]; then
80 ARCH_newFormat=32
81else
82 ARCH_newFormat=32e
83fi
84OS_newFormat=.
85if [ $upperOS = "LINUX" ]; then
86 OS_newFormat=lin
87elif [ $upperOS = "MACOSX" ]; then
88 OS_newFormat=mac
89elif [ $upperOS = "WINDOWS" ]; then
90 OS_newFormat=win
91elif [ $upperOS = "DARWIN" ]; then
92 OS_newFormat=dar
93else
94 OS_newFormat=unknown
95fi
96OS_PATH+=$OS_newFormat"_"$ARCH_newFormat
97
98# test and create directory
99if [ ! -d "$LEVEL" ]; then
100 mkdir $LEVEL
101 mkdir $OS_PATH
102else
103 if [ ! -d "$OS_PATH" ]; then
104 mkdir $OS_PATH
105 fi
106fi
107
108# reserve the tmp path to LLVM-IR/ARCH/OS
109echo $OS_PATH"/" > lit.tmp
110
111# OS_ARCH=$OS_newFormat"_"$ARCH_newFormat
112# echo -e "if not '$OS_ARCH' in config.root.targets:" > $OS_PATH'/'lit.local.cfg
113# echo -e "\tconfig.unsupported = True" >> $OS_PATH'/'lit.local.cfg
114
115# copy *.ll files to ARCH/OS
116`cp lit.* $LEVEL`
117
118# omit orph test
119`rm c-$MACHTYPE$OSTYPE/ctest_*.ll`
120`rm c-$MACHTYPE$OSTYPE/orph_ctest_*.ll`
121`cp c-$MACHTYPE$OSTYPE/*.ll $OS_PATH`
122
123# clean
124`rm /tmp/tmp.*`
125rm -rf c-$MACHTYPE$OSTYPE/