unknown commited on
Commit
6705032
·
1 Parent(s): d9cb2a1
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. LICENSE +21 -0
  3. README.md +318 -0
  4. Scripts/Exp/Accuracy/Accurate_Func_Merged.csv +171 -0
  5. Scripts/Exp/Accuracy/calculate_accuracy.py +178 -0
  6. Scripts/Exp/Accuracy/calculate_purple.py +42 -0
  7. Scripts/Exp/Accuracy/wrong_func_list_def.csv +366 -0
  8. Scripts/Exp/Correction/Correction_Time.xlsx +0 -0
  9. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterBankInfo/RegisterBankInfo.cpp +2 -0
  10. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/RegisterInfo.cpp +2 -0
  11. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/eliminateFrameIndex.cpp +10 -0
  12. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getCallPreservedMask.cpp +14 -0
  13. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getCalleeSavedRegs.cpp +21 -0
  14. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getFrameRegister.cpp +9 -0
  15. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getNoPreservedMask.cpp +1 -0
  16. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getPointerRegClass.cpp +15 -0
  17. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getReservedRegs.cpp +65 -0
  18. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/hasReservedSpillSlot.cpp +1 -0
  19. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/isAsmClobberable.cpp +1 -0
  20. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/isConstantPhysReg.cpp +1 -0
  21. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/requiresFrameIndexScavenging.cpp +3 -0
  22. Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/requiresRegisterScavenging.cpp +3 -0
  23. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/AsmParser.cpp +24 -0
  24. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/KindTy.cpp +7 -0
  25. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/LLVMInitializeAsmParser.cpp +6 -0
  26. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/MatchAndEmitInstruction.cpp +142 -0
  27. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/Operand.cpp +2 -0
  28. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/Operand2.cpp +2 -0
  29. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/ParseDirective.cpp +243 -0
  30. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/ParseInstruction.cpp +38 -0
  31. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/ParseRegister.cpp +3 -0
  32. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addCSRSystemRegisterOperands.cpp +1 -0
  33. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addExpr.cpp +8 -0
  34. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addFRMArgOperands.cpp +1 -0
  35. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addFenceArgOperands.cpp +1 -0
  36. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addImmOperands.cpp +4 -0
  37. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addRegOperands.cpp +3 -0
  38. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addVTypeIOperands.cpp +1 -0
  39. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/classifySymbolRef.cpp +1 -0
  40. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/convertFPR64ToFPR16.cpp +1 -0
  41. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/convertFPR64ToFPR32.cpp +1 -0
  42. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createImm.cpp +7 -0
  43. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createReg.cpp +11 -0
  44. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createSysReg.cpp +1 -0
  45. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createToken.cpp +8 -0
  46. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createVType.cpp +1 -0
  47. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/defaultMaskRegOp.cpp +1 -0
  48. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/emitToStreamer.cpp +1 -0
  49. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/evaluateConstantImm.cpp +1 -0
  50. Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/generateImmOutOfRangeError.cpp +1 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.jsonl filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) Microsoft Corporation.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: "VEGA"
3
+ language:
4
+ - code
5
+ tags:
6
+ - C++/C Code
7
+ - Compiler Backend
8
+ license: "cc-by-4.0"
9
+ ---
10
+
11
+ # VEGA: Automatically Generating Compiler Backends Using a Pre-Trained Transformer Model
12
+
13
+ VEGA is an AI-driven system aimed at easing the development burden of compiler backends for new targets.
14
+
15
+ This repository contains code and data for reproducing experimental results.
16
+
17
+ For detailed description of each script, please refer to the Artifact Appendix of our paper.
18
+
19
+
20
+ ## 1. Directory Structure
21
+ ```
22
+ VEGA_AE
23
+ |──dataset
24
+ |──saved_models
25
+ | |──Fine_Tuned_Model
26
+ | |──New_Fine_Tuned_Model
27
+ | └──UnixCoder
28
+ |——Scripts
29
+ | |──Exp
30
+ | | |──Accuracy
31
+ | | |──Correction
32
+ | | |──ForkFlow
33
+ | | |──Performance
34
+ | | └──Time
35
+ | └──UnixCoder
36
+ └──Fixed_VEGA_LLVM
37
+ |──llvm-riscv
38
+ |──llvm-ri5cy
39
+ └──llvm-xcore
40
+ ```
41
+ ## 2. Hardware Dependency
42
+
43
+ - Intel(R)Xeon(R)Gold 6132 CPU @ 2.60GHz
44
+ - 8 Nvidia Tesla V100 GPU, each with 16 GB Memory
45
+
46
+ ## 3. Software Dependency
47
+ - CUDA == 11.4
48
+ - python version == 3.8.1
49
+ - pip install -r requirements.txt
50
+
51
+
52
+ ## 4. Fine-Tuning
53
+
54
+ Run fine-tuning with:
55
+ ```
56
+ $ bash run_fine_tuning.sh
57
+ ```
58
+ Customize parameters for fine-tuning by modifying following options in the ```run_fine_tuning.sh```.
59
+ ```
60
+ --model_name_or_path ../../saved_models/UnixCoder \
61
+ --train_filename ../../dataset/train.jsonl \
62
+ --dev_filename ../../dataset/valid.jsonl \
63
+ --output_dir ../../saved_models/New_Fine_Tuned_Model \
64
+ --beam_size 4 \
65
+ --train_batch_size 96 \
66
+ --eval_batch_size 80 \
67
+ --learning_rate 6e-5 \
68
+ --num_train_epochs 50 \
69
+ --mse_loss_weight 0.9 \
70
+ --ce_loss_weight 0.1
71
+ ```
72
+ The fine-tuned model will be saved in ```--output_dir```.
73
+
74
+ ## 5. Code Generation
75
+
76
+ We have provided a fine-tuned model in ```./saved_models/Fine_Tuned_Model```.
77
+
78
+ We have also provided a script fot function test, which only generates a single function for RI5CY, taking less than 3 minutes with 8 V100 GPU.
79
+
80
+
81
+
82
+ Run function test with:
83
+
84
+ ```
85
+ $ bash run_function_test.sh
86
+ ```
87
+
88
+ When the ```run_function_test.sh``` script begins execution, the command line displays
89
+ ```
90
+ $ " Start Function Inferencing !"
91
+ ```
92
+ Upon completion of the code generation, the script outputs
93
+ ```
94
+ $ " Finished Function Inferencing : xxx secs"
95
+ ```
96
+
97
+ The inference result will be saved in ```--output_dir/result.jsonl```.
98
+
99
+ Run code generation with:
100
+
101
+ ```
102
+ $ bash run_test.sh
103
+ ```
104
+
105
+ Customize parameters for inferencing by modifying following options in the ```run_test.sh```.
106
+ ```
107
+ --model_name_or_path ../../saved_models/UnixCoder \
108
+ --test_filename ../../dataset/test.jsonl \
109
+ --output_dir ../../saved_models/Fine_Tuned_Model \
110
+ --beam_size 4 \
111
+ --train_batch_size 256 \
112
+ --eval_batch_size 256 \
113
+ --learning_rate 6e-5 \
114
+ --gradient_accumulation_steps 2 \
115
+ --num_train_epochs 10 \
116
+ --mse_loss_weight 0.9 \
117
+ --ce_loss_weight 0.1
118
+ ```
119
+ Users can inference with their own fine-tuned model by changing the ```--output_dir``` option.
120
+
121
+
122
+
123
+ When the ```run_test.sh``` script begins execution, the command line displays
124
+ ```
125
+ $ " Start Inferencing !"
126
+ ```
127
+ Upon completion of the code generation, the script outputs
128
+ ```
129
+ $ " Finished Inferencing : xxx secs"
130
+ ```
131
+
132
+ The inference result will be saved in ```--output_dir/result.jsonl```.
133
+
134
+ The ```--output_dir``` parameter specifies the directory where the fine-tuned model is saved, such as ```./saved_models/Fine_Tuned_Model```.
135
+
136
+ ## 6. Reproducing Results in the Experiment
137
+
138
+ We provide the scripts to reproduce each Figure/Table from the paper, along with the corresponding output result files, in the following table:
139
+
140
+
141
+ | Script | Description | Output | Figure/Table |
142
+ | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | -------------- |
143
+ | ./Scripts/Exp/Time/calculate_time.py | Calculate the time overhead. | ./Scripts/Exp/Time/time_overhead.csv | Fig.7 |
144
+ | ./Scripts/Exp/Accuracy/calculate_accuracy.py | Calculate the function-level accuracy. | ./Scripts/Exp/Accuracy/vega_result.csv | Fig.8 |
145
+ | ./Scripts/Exp/Accuracy/calculate_purple.py | Calculate the the percentage of functions accurately synthesized from the statements of various existing targets (Purple Bar in Fig.8). | ./Scripts/Exp/Accuracy/fig8_purple.csv | Fig.8 |
146
+ | ./Scripts/Exp/Accuracy/calculate_accuracy.py | Calculate the percentage of three types of error. | ./Scripts/Exp/Accuracy/err_percentage.csv | Table.2 |
147
+ | ./Scripts/Exp/ForkFlow/calculate_forkflow.py | Calculate the statement-level accracy of VEGA and ForkFlow. | ./Scripts/Exp/ForkFlow/forkflow_result.csv | Fig.9 |
148
+ | ./Scripts/Exp/ForkFlow/calculate_forkflow.py | Calculate the number of accurate statements of VEGA and ForkFlow. | ./Scripts/Exp/ForkFlow/mod_lines.csv | Table.3 |
149
+ | - | Recorded time required by Developer A and B to modify the VEGA-generated RISC-V backend. | ./Scripts/Exp/Correction/Correction_Time.xlsx | Table. 4 |
150
+ | - | Recorded time required for LLVM-Base (-O0), LLVM-Base (-O3), and LLVM-VEGA (-O3) to pass benchmarks. | ./Scripts/Exp/Performance/BenchMark.xlsx | Fig. 10 |
151
+ ### 6.1 Results for Fig. 7 in Sec. 4.2
152
+
153
+ In the code generation process, we set a batch size of 256 on 8 Nvidia Tesla V100 GPU (each with 16GB memory), meaning each batch contains 256 statements. Since each batch may include statements from different function modules, we did not directly measure the generation time for each function modules of three targets (RISC-V, RI5CY, xCORE) during execution. Instead, we calculated the average inference time of each batch (25 seconds) and then derived the inference time of each statement (25/256 seconds). With the total number of statements within each function module of each target, we subsequently calculated the total inference time required for each function module of each target.
154
+
155
+
156
+ - Command:
157
+ ```
158
+ $ python ./Scripts/Exp/Time/calculate_time.py
159
+ ```
160
+
161
+
162
+ - Results:
163
+ ```
164
+ ./Scripts/Exp/Time/time_overhead.csv
165
+ ```
166
+
167
+ ### 6.2 Results for Fig. 8 in Sec. 4.2
168
+
169
+
170
+ In our experiment, we employed the Pass@1 evaluation metric, which involves replacing each VEGA-generated function individually within the official LLVM (LLVM-Base), then running regression tests to verify the correctness of the replaced function. This process is highly time-intensive, as a single regression test run generally takes about half an hour. Thus, sequentially testing all 1,454 VEGA-generated functions across three targets would require approximately 727 hours.
171
+
172
+ To simplify this process, we recorded the ground truth for each statement based on the Pass@1 experiment results. Additionally, we documented a list of functions containing Err-Def errors (i.e., errors due to missing necessary statements in the function template; functions with Err-Def can not pass all regression tests). This allowed us to transform the Pass@1 testing process into an Exact Match evaluation.
173
+
174
+ In this Exact Match evaluation, each statement is deemed correct if the VEGA-generated code matches the ground truth and the confidence score aligns. A function is considered correct if all statements within it are accurate and it is free from Err-Def errors.
175
+
176
+ - Command:
177
+ ```
178
+ $ cp --output_dir/result.jsonl ./Scripts/Exp/Accuracy
179
+ $ python ./Scripts/Exp/Accuracy/calculate_accuracy.py
180
+ ```
181
+
182
+ This script will automatically analyze the VEGA's output from "result.jsonl" and compare the generated code and confidence scores with the ground truth. Based on this comparison, it will determine whether each function is correct.
183
+
184
+ - Accuracy Results:
185
+ ```
186
+ ./Scripts/Exp/Accuracy/vega_result.csv
187
+ ```
188
+
189
+
190
+ We also provide a script for calculating the proportion of "Accurate Functions with Integrated Statements Across Multiple Targets". The value corresponding to the purple bar in Fig. 8.
191
+
192
+
193
+ - Command:
194
+ ```
195
+ $ python ./Scripts/Exp/Accuracy/calculate_purple.py
196
+ ```
197
+
198
+
199
+ - Results:
200
+ ```
201
+ ./Scripts/Exp/Accuracy/fig8_purple.csv
202
+ ```
203
+
204
+
205
+ We also provided manually fixed VEGA-generated RISC-V, RI5CY and xCORE backend, which can be used to run regression tests and pass@1 experiments. **Note that the compilation of llvm-riscv and llvm-ri5cy requires gcc-9.5.0 version, and the compilation of llvm-xcore requires gcc-4.0.0 version.**
206
+
207
+ ```
208
+ Download from Google Drive: https://drive.google.com/file/d/1VD3H60vMvtnRtMkS6h0qZWTKkjcUzLsw/view?usp=drive_link
209
+ $ unzip Fixed_VEGA_LLVM.zip
210
+ ```
211
+
212
+ - Command for Running RISC-V Backend:
213
+ ```
214
+ $ cd ./Fixed_VEGA_LLVM
215
+ $ bash run_llvm_riscv.sh
216
+ ```
217
+ - Results for Regression Tests of the RISC-V Backend:
218
+ ```
219
+ $ Testing Time: xxx s
220
+ $ Passed : 16005
221
+ ```
222
+
223
+ - Command for Running RI5CY Backend:
224
+ ```
225
+ $ cd ./Fixed_VEGA_LLVM
226
+ $ bash run_llvm_ri5cy.sh
227
+ ```
228
+ - Results for Regression Tests of the RI5CY Backend:
229
+ ```
230
+ $ Testing Time: xxx s
231
+ $ Passed : 16040
232
+ ```
233
+
234
+ - Command for Running xCORE Backend:
235
+ ```
236
+ $ cd ./Fixed_VEGA_LLVM
237
+ $ vim run_llvm_xcore.sh
238
+ $ Set the prefix option to the path where you want to install LLVM.
239
+ $ Set the CC and llvmgccdir option to the path of gcc-4.0.0 version, change the CXX option to the path of g++-4.0.0 version.
240
+ $ bash run_llvm_xcore.sh
241
+ ```
242
+ - Results for Regression Tests of the xCORE Backend:
243
+ ```
244
+ $ Testing Time: xxx s
245
+ $ Passed : 5466
246
+ ```
247
+
248
+ ### 6.3 Results for Table. 2 in Sec. 4.2
249
+
250
+ Executing the script in (2) will also yield the proportion of the three types of errors for each target.
251
+
252
+
253
+ - Command:
254
+ ```
255
+ $ python ./Scripts/Exp/Accuracy/calculate_accuracy.py
256
+ ```
257
+
258
+
259
+ - Results:
260
+ ```
261
+ ./Scripts/Exp/Accuracy/err_percentage.csv
262
+ ```
263
+
264
+
265
+ ### 6.4 Results for Fig. 9 in Sec. 4.2
266
+
267
+ We modified the functions generated by VEGA and functions in the MIPS backend (ForkFlow) to ensure they can correctly run on the RISC-V, RI5CY, and xCORE backends respectively. By executing the following script, the proportion of accurate and modified statements of the VEGA-generated functions and ForkFlow processes will be automatically calculated.
268
+
269
+ - Command:
270
+ ```
271
+ $ python ./Scripts/Exp/ForkFlow/calculate_forkflow.py
272
+ ```
273
+
274
+
275
+ - Results:
276
+ ```
277
+ ./Scripts/Exp/ForkFlow/forkflow_result.csv
278
+ ```
279
+
280
+ ### 6.5 Results for Table. 3 in Sec. 4.2
281
+
282
+ Executing the script in 6.4 will also output the number of statements accurately generated and requiring manual correction by VEGA across seven function modules for RISC-V, RI5CY, and xCORE.
283
+
284
+
285
+ - Command:
286
+ ```
287
+ $ python ./Scripts/Exp/ForkFlow/calculate_forkflow.py
288
+ ```
289
+
290
+
291
+ - Results:
292
+ ```
293
+ ./Scripts/Exp/ForkFlow/mod_lines.csv
294
+ ```
295
+
296
+
297
+ ### 6.6 Results for Table. 4 in Sec. 4.2
298
+
299
+ The data in Table. 4 record the time required by two developers to modify the VEGA-generated RISC-V backend. As this is a human-based experiment, we can only provide the recorded time for modifying each function within the VEGA-generated RISC-V backend.
300
+
301
+ - Results:
302
+ ```
303
+ ./Scripts/Exp/Correction/Correction_Time.xlsx
304
+ ```
305
+
306
+ This file contains two sheets, each corresponding to the time required by Developer A and Developer B to modify the VEGA-generated RISC-V backend. Each sheet includes four columns: the first three indicate the function module, file, and function name of each function in the VEGA-generated RISC-V backend, while the final column specifies the time spent modifying each function, measured in seconds. By summing the data in each sheet according to function modules, we calculated the total time (in hours) that Developer A and Developer B spent on each module.
307
+
308
+ ### 6.7 Results for Fig. 10 in Sec. 4.3
309
+
310
+ Due to restrictions associated with the commercial license, we are unable to provide the source code of the SPEC 2017 CPU benchmark directly used in this experiment. Furthermore, the testing duration for SPEC 2017 CPU is highly time-consuming, requiring approximately 565 hours. To address these constraints, we provide our recorded experimental data, which can be accessed at:
311
+
312
+
313
+ - Results:
314
+ ```
315
+ ./Scripts/Exp/Performance/BenchMark.xlsx
316
+ ```
317
+
318
+ Each sheet in this recorded data is named with the experimental target and benchmark tested, e.g., "RISCV (SPEC 2017CPU)". We recorded the time required for LLVM-Base (-O0), LLVM-Base (-O3), and LLVM-VEGA (-O3) to successfully pass each test case, and calculated the corresponding speedup ratios respectively.
Scripts/Exp/Accuracy/Accurate_Func_Merged.csv ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Allocation,RegisterInfo,getCalleeSavedRegs,PULP
2
+ Allocation,RegisterInfo,getFrameRegister,PULP
3
+ Assembler,AsmParser,isRV64,PULP
4
+ Assembler,AsmParser,isRV64-2,PULP
5
+ Assembler,AsmParser,isSImm6NonZero,PULP
6
+ Assembler,AsmParser,isSImm9Lsb0,PULP
7
+ Assembler,AsmParser,parseImmediate,PULP
8
+ Assembler,AsmParser,validateTargetOperandClass,PULP
9
+ Assembler,AsmPrinter,isSImm12Lsb0,PULP
10
+ Disassembler,Disassembler,addImplySP,PULP
11
+ Disassembler,Disassembler,DecodePulpV2RegisterClass,PULP
12
+ Disassembler,Disassembler,DecodePulpV4RegisterClass,PULP
13
+ Disassembler,Disassembler,decodeSImmNonZeroOperand,PULP
14
+ Disassembler,Disassembler,decodeUImmNonZeroOperand,PULP
15
+ Disassembler,Disassembler,DecodeVRRegisterClass,PULP
16
+ Disassembler,Disassembler,LLVMInitializeDisassembler,PULP
17
+ Emission,AsmBackend,applyFixup,PULP
18
+ Emission,AsmBackend,fixupNeedsRelaxationAdvanced,PULP
19
+ Emission,AsmBackend,getFixupKind,PULP
20
+ Emission,AsmBackend,getRelaxedOpcode,PULP
21
+ Emission,AsmBackend,mayNeedRelaxation,PULP
22
+ Emission,AsmInfo,MCAsmInfo,PULP
23
+ Emission,BaseInfo,ABI,PULP
24
+ Emission,BaseInfo,getTargetABI,PULP
25
+ Emission,BaseInfo,stringToRoundingMode,PULP
26
+ Emission,BaseInfo,VLMUL,PULP
27
+ Emission,ELFObjectWriter,getRelocType,PULP
28
+ Emission,ELFStreamer,calculateContentSize,PULP
29
+ Emission,ELFStreamer,setAttributeItem1,PULP
30
+ Emission,ELFStreamer,setAttributeItem2,PULP
31
+ Emission,ELFStreamer,setAttributeItems,PULP
32
+ Emission,FixupKind,enumFixups,PULP
33
+ Emission,InstPrinter,printBranchOperand,PULP
34
+ Emission,MCCodeEmitter,getVMaskReg,PULP
35
+ Emission,MCExpr,enumVariantKind,PULP
36
+ Emission,MCExpr,printImpl,PULP
37
+ Emission,MCTargetDesc,evaluateBranch,PULP
38
+ Emission,MCTargetDesc,LLVMInitializeTargetMC,PULP
39
+ Optimization,CleanupVSETVLI,getRequiredProperties,PULP
40
+ Optimization,MergeBaseOffset,getRequiredProperties,PULP
41
+ Optimization,PULPHardWareLoops,containsInvalidInstruction,PULP
42
+ Optimization,PULPHardWareLoops,getComparisonKind,PULP
43
+ Optimization,PULPHardWareLoops,getNegatedComparison,PULP
44
+ Optimization,PULPHardWareLoops,getSwappedComparison,PULP
45
+ Optimization,SNITCHFrepLoops,getComparisonKind,PULP
46
+ Scheduling,InstrInfo,isFunctionSafeToOutlineFrom,PULP
47
+ Scheduling,InstrInfo,isLoadFromStackSlot,PULP
48
+ Scheduling,InstrInfo,isMBBSafeToOutlineFrom,PULP
49
+ Scheduling,InstrInfo,isStoreToStackSlot,PULP
50
+ Scheduling,InstrInfo,loadRegFromStackSlot,PULP
51
+ Scheduling,InstrInfo,storeRegToStackSlot,PULP
52
+ Scheduling,MachineFunctionInfo,getUsedSSR,PULP
53
+ Scheduling,Subtarget,enableLinkerRelax,PULP
54
+ Scheduling,Subtarget,enableRVCHintInstrs,PULP
55
+ Scheduling,Subtarget,enableSaveRestore,PULP
56
+ Scheduling,Subtarget,getXLen,PULP
57
+ Scheduling,Subtarget,getXLenVT,PULP
58
+ Scheduling,Subtarget,is64Bit,PULP
59
+ Scheduling,TargetInfo,LLVMInitializeTargetInfo,PULP
60
+ Scheduling,TargetMachine,addPreEmitPass2,PULP
61
+ Scheduling,TargetMachine,LLVMInitializeTarget,PULP
62
+ Scheduling,TargetObjectFile,getSectionForConstant,PULP
63
+ Scheduling,TargetTransformInfo,getIntImmCostIntrin,PULP
64
+ Selection,FrameLowering,hasBP,PULP
65
+ Selection,FrameLowering,hasFP,PULP
66
+ Selection,FrameLowering,hasReservedCallFrame,PULP
67
+ Selection,InstructionSelector,InstructionSelector,PULP
68
+ Selection,ISelDAGToDAG,SelectAddrFI,PULP
69
+ Selection,ISelLowering,getConstraintType,PULP
70
+ Selection,ISelLowering,getInlineAsmMemConstraint,PULP
71
+ Selection,ISelLowering,getPointerMemTy,PULP
72
+ Selection,ISelLowering,getPointerTy,PULP
73
+ Selection,ISelLowering,getScalarShiftAmountTy,PULP
74
+ Selection,ISelLowering,getTargetNodeName,PULP
75
+ Selection,ISelLowering,isLegalAddressingMode,PULP
76
+ Selection,ISelLowering,LowerAsmOperandForConstraint,PULP
77
+ Selection,ISelLowering,LowerGlobalAddress,PULP
78
+ Selection,ISelLowering,LowerGlobalTLSAddress,PULP
79
+ Selection,ISelLowering,lowerJumpTable,PULP
80
+ Selection,ISelLowering,lowerSELECT,PULP
81
+ Selection,ISelLowering,mayBeEmittedAsTailCall,PULP
82
+ Selection,ISelLowering,NodeType,PULP
83
+ Selection,ISelLowering,shouldExpandAtomicCmpXchgInIR,PULP
84
+ Selection,ISelLowering,shouldExpandAtomicRMWInIR,PULP
85
+ Selection,ISelLowering,shouldSignExtendTypeInLibCall,PULP
86
+ Selection,MCInstLower,lowerMachineOperandToMCOperand,PULP
87
+ Selection,MCInstLower,lowerSymbolOperand,PULP
88
+ Allocation,RegisterInfo,getCalleeSavedRegs,RISCV
89
+ Allocation,RegisterInfo,getFrameRegister,RISCV
90
+ Allocation,RegisterInfo,getReservedRegs,RISCV
91
+ Assembler,AsmParser,isRV64,RISCV
92
+ Assembler,AsmParser,isRV64-2,RISCV
93
+ Assembler,AsmParser,isSImm6NonZero,RISCV
94
+ Assembler,AsmParser,isSImm9Lsb0,RISCV
95
+ Assembler,AsmParser,parseImmediate,RISCV
96
+ Assembler,AsmParser,parseOperand,RISCV
97
+ Assembler,AsmParser,validateTargetOperandClass,RISCV
98
+ Assembler,AsmPrinter,isSImm12Lsb0,RISCV
99
+ Disassembler,Disassembler,addImplySP,RISCV
100
+ Disassembler,Disassembler,decodeSImmNonZeroOperand,RISCV
101
+ Disassembler,Disassembler,decodeUImmNonZeroOperand,RISCV
102
+ Disassembler,Disassembler,DecodeVRRegisterClass,RISCV
103
+ Disassembler,Disassembler,LLVMInitializeDisassembler,RISCV
104
+ Emission,AsmBackend,applyFixup,RISCV
105
+ Emission,AsmBackend,fixupNeedsRelaxationAdvanced,RISCV
106
+ Emission,AsmBackend,getFixupKind,RISCV
107
+ Emission,AsmBackend,getRelaxedOpcode,RISCV
108
+ Emission,AsmBackend,mayNeedRelaxation,RISCV
109
+ Emission,AsmInfo,MCAsmInfo,RISCV
110
+ Emission,BaseInfo,ABI,RISCV
111
+ Emission,BaseInfo,getTargetABI,RISCV
112
+ Emission,BaseInfo,stringToRoundingMode,RISCV
113
+ Emission,BaseInfo,VLMUL,RISCV
114
+ Emission,ELFObjectWriter,getRelocType,RISCV
115
+ Emission,ELFStreamer,calculateContentSize,RISCV
116
+ Emission,ELFStreamer,setAttributeItem1,RISCV
117
+ Emission,ELFStreamer,setAttributeItem2,RISCV
118
+ Emission,ELFStreamer,setAttributeItems,RISCV
119
+ Emission,InstPrinter,printBranchOperand,RISCV
120
+ Emission,MCCodeEmitter,getVMaskReg,RISCV
121
+ Emission,MCExpr,enumVariantKind,RISCV
122
+ Emission,MCExpr,printImpl,RISCV
123
+ Emission,MCTargetDesc,LLVMInitializeTargetMC,RISCV
124
+ Optimization,CleanupVSETVLI,getRequiredProperties,RISCV
125
+ Optimization,CleanupVSETVLI,runOnMachineFunction,RISCV
126
+ Optimization,MergeBaseOffset,getRequiredProperties,RISCV
127
+ Scheduling,InstrInfo,isFunctionSafeToOutlineFrom,RISCV
128
+ Scheduling,InstrInfo,isLoadFromStackSlot,RISCV
129
+ Scheduling,InstrInfo,isMBBSafeToOutlineFrom,RISCV
130
+ Scheduling,InstrInfo,isStoreToStackSlot,RISCV
131
+ Scheduling,InstrInfo,loadRegFromStackSlot,RISCV
132
+ Scheduling,InstrInfo,storeRegToStackSlot,RISCV
133
+ Scheduling,Subtarget,enableLinkerRelax,RISCV
134
+ Scheduling,Subtarget,enableRVCHintInstrs,RISCV
135
+ Scheduling,Subtarget,enableSaveRestore,RISCV
136
+ Scheduling,Subtarget,getXLen,RISCV
137
+ Scheduling,Subtarget,getXLenVT,RISCV
138
+ Scheduling,Subtarget,is64Bit,RISCV
139
+ Scheduling,TargetInfo,LLVMInitializeTargetInfo,RISCV
140
+ Scheduling,TargetMachine,addPreEmitPass2,RISCV
141
+ Scheduling,TargetMachine,LLVMInitializeTarget,RISCV
142
+ Scheduling,TargetObjectFile,getSectionForConstant,RISCV
143
+ Scheduling,TargetTransformInfo,getIntImmCostIntrin,RISCV
144
+ Selection,FrameLowering,hasBP,RISCV
145
+ Selection,FrameLowering,hasFP,RISCV
146
+ Selection,FrameLowering,hasReservedCallFrame,RISCV
147
+ Selection,InstructionSelector,InstructionSelector,RISCV
148
+ Selection,ISelDAGToDAG,SelectAddrFI,RISCV
149
+ Selection,ISelLowering,getConstraintType,RISCV
150
+ Selection,ISelLowering,getInlineAsmMemConstraint,RISCV
151
+ Selection,ISelLowering,getTargetNodeName,RISCV
152
+ Selection,ISelLowering,isLegalAddressingMode,RISCV
153
+ Selection,ISelLowering,LowerAsmOperandForConstraint,RISCV
154
+ Selection,ISelLowering,LowerGlobalAddress,RISCV
155
+ Selection,ISelLowering,LowerGlobalTLSAddress,RISCV
156
+ Selection,ISelLowering,lowerJumpTable,RISCV
157
+ Selection,ISelLowering,lowerSELECT,RISCV
158
+ Selection,ISelLowering,mayBeEmittedAsTailCall,RISCV
159
+ Selection,ISelLowering,NodeType,RISCV
160
+ Selection,ISelLowering,shouldExpandAtomicCmpXchgInIR,RISCV
161
+ Selection,ISelLowering,shouldExpandAtomicRMWInIR,RISCV
162
+ Selection,ISelLowering,shouldSignExtendTypeInLibCall,RISCV
163
+ Selection,MCInstLower,lowerMachineOperandToMCOperand,RISCV
164
+ Selection,MCInstLower,lowerSymbolOperand,RISCV
165
+ Emission,MCTargetDesc,LLVMInitializeTargetMC,XCore
166
+ Scheduling,InstrInfo,GetCondBranchFromCond,XCore
167
+ Scheduling,InstrInfo,GetOppositeBranchCondition,XCore
168
+ Scheduling,InstrInfo,IsCondBranch,XCore
169
+ Scheduling,TargetMachine,addPreEmitPass,XCore
170
+ Selection,ISelLowering,enumNodeType,XCore
171
+ Selection,ISelLowering,getTargetNodeName,XCore
Scripts/Exp/Accuracy/calculate_accuracy.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, sys,string,re,glob
2
+
3
+ import json
4
+ import csv
5
+ import copy
6
+
7
+
8
+ import pathlib
9
+ import time
10
+
11
+ folder = str(pathlib.Path(__file__).parent.resolve())
12
+ #Total_encas
13
+
14
+ func_num_dic = {
15
+ "riscv" : 568,
16
+ "pulp" : 698,
17
+ "xcore" : 188
18
+ }
19
+
20
+
21
+
22
+ wrong_lis_all = []
23
+ wrong_stmt = []
24
+ err_def_dic = {}
25
+ def get_wrong_list():
26
+ global wrong_stmt
27
+ global wrong_lis_all
28
+ global err_def_dic
29
+ with open(folder+"/wrong_func_list_def.csv", 'r', encoding='utf-8') as fcsv:
30
+ reader = csv.reader(fcsv)
31
+ for row in reader:
32
+ if row[0] == "idx":
33
+ continue
34
+ wrong_stmt.append(row[0].strip().lower() + " " + row[1].strip().lower() + " " + row[2].strip().lower())
35
+ wrong_lis_all.append(" ".join(row))
36
+ if " ".join([row[2], row[3]]) not in err_def_dic.keys():
37
+ err_def_dic[" ".join([row[2], row[3]])]= 1
38
+ else:
39
+ err_def_dic[" ".join([row[2], row[3]])] += 1
40
+
41
+ def calculate_accuracy():
42
+ func_res = {}
43
+ stable_stmt_dic = {}
44
+ all_func_lis = []
45
+ global wrong_stmt
46
+ global wrong_lis_all
47
+ global err_def_dic
48
+ total_dic = {}
49
+ wrong_dic = {}
50
+ asm_file = []
51
+ for line in open(folder+"/result.jsonl", 'r', encoding="utf-8"):
52
+ dic = json.loads(line)
53
+ all_func_lis.append(dic["File"].strip().lower() + " " + dic["Func"].strip().lower() + " " + dic["Target"].strip().lower())
54
+
55
+ if int(dic["vega_pre"]) == 1:
56
+ if " ".join([dic["Target"], dic["Module"], dic["File"], dic["Func"]]) not in func_res.keys():
57
+ func_res[" ".join([dic["Target"], dic["Module"], dic["File"], dic["Func"]])] = [dic["vega_code"].replace("zmtarzm", dic["Target"])]
58
+ else:
59
+ func_res[" ".join([dic["Target"], dic["Module"], dic["File"], dic["Func"]])].append(dic["vega_code"].replace("zmtarzm", dic["Target"]))
60
+ if " ".join([dic["Target"], dic["Module"]]) not in stable_stmt_dic.keys():
61
+ stable_stmt_dic[" ".join([dic["Target"], dic["Module"]])] = [0, 0]
62
+ if dic["Stable"].lower() == "true":
63
+ stable_stmt_dic[" ".join([dic["Target"], dic["Module"]])][0] += 1
64
+ stable_stmt_dic[" ".join([dic["Target"], dic["Module"]])][1] += 1
65
+ else:
66
+ stable_stmt_dic[" ".join([dic["Target"], dic["Module"]])][1] += 1
67
+
68
+ if dic["Target"] + " " + dic["Module"] not in total_dic.keys():
69
+ total_dic[dic["Target"] + " " + dic["Module"]] = [dic["File"].strip() + " " + dic["Func"].strip() + " " + dic["Target"].strip()]
70
+ wrong_dic[dic["Target"] + " " + dic["Module"]] = []
71
+ else:
72
+ total_dic[dic["Target"] + " " + dic["Module"]].append(dic["File"].strip() + " " + dic["Func"].strip() + " " + dic["Target"].strip())
73
+ if dic["File"].strip().lower() + " " + dic["Func"].strip().lower() + " " + dic["Target"].strip().lower() in wrong_stmt:
74
+ #print(dic["File"].strip() + " " + dic["Func"].strip() + " " + dic["Target"].strip())
75
+ wrong_dic[dic["Target"] + " " + dic["Module"]].append(dic["File"].strip() + " " + dic["Func"].strip() + " " + dic["Target"].strip())
76
+ if dic["ans_code"].replace(" ", "") != dic["vega_code"].replace(" ", "") or dic["ans_pre"] != dic["vega_pre"]:
77
+ wrong_dic[dic["Target"] + " " + dic["Module"]].append(dic["File"].strip() + " " + dic["Func"].strip() + " " + dic["Target"].strip())
78
+ if dic["ans_code"] != dic["vega_code"]:
79
+ wrong_lis_all.append(" ".join([dic["File"], dic["Func"], dic["Target"], dic["Module"], "Err_V"]))
80
+ if dic["ans_pre"] != dic["vega_pre"]:
81
+ wrong_lis_all.append(" ".join([dic["File"], dic["Func"], dic["Target"], dic["Module"], "Err_CS"]))
82
+
83
+ all_func_lis = list(set(all_func_lis))
84
+
85
+ with open(folder+"/vega_result.csv", 'a', encoding='utf-8', newline="") as f:
86
+ f_csv = csv.writer(f)
87
+ avg_dic = {}
88
+ all_dic = {}
89
+ for k in total_dic.keys():
90
+ Correct_Func_Num = len(list(set(total_dic[k])))-len(list(set(wrong_dic[k])))
91
+ Total_Func_Num = len(list(set(total_dic[k])))
92
+ Accuracy_Func = 1-round(len(list(set(wrong_dic[k]))) * 1.0 / len(list(set(total_dic[k]))), 3)
93
+ Wrong_Func_Percentage = round(len(list(set(wrong_dic[k]))) * 1.0 / len(list(set(total_dic[k]))), 3)
94
+ Pre_Equal_1_Stmt_Percentage = round(stable_stmt_dic[k][0]/stable_stmt_dic[k][1], 3)
95
+ Pre_Less_1_Stmt_Percentage = 1 - round(stable_stmt_dic[k][0]/stable_stmt_dic[k][1], 3)
96
+ if k.split(" ")[0] not in avg_dic.keys():
97
+ avg_dic[k.split(" ")[0]] = Accuracy_Func
98
+ all_dic[k.split(" ")[0]] = Correct_Func_Num
99
+ else:
100
+ avg_dic[k.split(" ")[0]] += Accuracy_Func
101
+ all_dic[k.split(" ")[0]] += Correct_Func_Num
102
+ tem_k = k.replace("PULP", "RI5CY")
103
+ f_csv.writerow(tem_k.split(" ") + [Correct_Func_Num, Total_Func_Num, Accuracy_Func, Wrong_Func_Percentage, Pre_Equal_1_Stmt_Percentage, Pre_Less_1_Stmt_Percentage])
104
+
105
+ for k in avg_dic:
106
+ if k.lower() == "riscv":
107
+ f_csv.writerow([k, "AVG", round(avg_dic[k] / 7.0, 3)])
108
+ f_csv.writerow([k, "ALL", round(all_dic[k] / func_num_dic[k.lower()], 3)])
109
+ elif k.lower() == "pulp":
110
+ f_csv.writerow(["RI5CY", "AVG", round(avg_dic[k] / 7.0, 3)])
111
+ f_csv.writerow(["RI5CY", "ALL", round(all_dic[k] / func_num_dic[k.lower()], 3)])
112
+ else:
113
+ f_csv.writerow([k, "AVG", round(avg_dic[k] / 6.0, 3)])
114
+ f_csv.writerow([k, "ALL", round(all_dic[k] / func_num_dic[k.lower()], 3)])
115
+
116
+
117
+
118
+ for k in func_res.keys():
119
+ Tar_Path = folder + "/../ForkFlow/VEGA_Code/" + "/".join(k.split(" ")) + ".cpp"
120
+ Tar_Path = Tar_Path.replace("enum/NodeType", "enum NodeType")
121
+ Tar_Path = Tar_Path.replace("enum/CondCode", "enum CondCode")
122
+ Tar_Path = Tar_Path.replace("ExpandSSRInsts/ExpandPseudo", "ExpandSSRInsts/ExpandSSRInsts")
123
+ if os.path.exists(Tar_Path):
124
+ with open(Tar_Path, 'w') as file:
125
+ for idx, l in enumerate(func_res[k]):
126
+ if idx < len(func_res[k])-1:
127
+ file.write(l)
128
+ file.write("\n")
129
+ else:
130
+ file.write(l)
131
+ else:
132
+ print(Tar_Path)
133
+
134
+ return total_dic
135
+
136
+
137
+ if __name__ == '__main__':
138
+ get_wrong_list()
139
+ with open(folder+"/vega_result.csv", 'w', encoding='utf-8', newline="") as f:
140
+ f_csv = csv.writer(f)
141
+ f_csv.writerow(["Target", "Module", "Correct", "Total", "Accurate", "Inaccurate", "Confidence Score≈1.00", "Confidence Score in [0.50, 1.00)"])
142
+ total_dic = calculate_accuracy()
143
+ wrong_lis_all = list(set(wrong_lis_all))
144
+ with open(folder+"/wrong_list_all.csv", 'w', encoding='utf-8', newline="") as f:
145
+ f_csv = csv.writer(f)
146
+ for err in wrong_lis_all:
147
+ f_csv.writerow(err.split(" "))
148
+ with open(folder+"/../ForkFlow/wrong_list_all.csv", 'w', encoding='utf-8', newline="") as f:
149
+ f_csv = csv.writer(f)
150
+ for err in wrong_lis_all:
151
+ f_csv.writerow(err.split(" "))
152
+
153
+ wrong_dic = {}
154
+ with open(folder+"/wrong_list_all.csv", 'r', encoding='utf-8') as f:
155
+ f_csv = csv.reader(f)
156
+ for row in f_csv:
157
+ if " ".join([row[-3].lower(), row[-1].lower()]) not in wrong_dic.keys():
158
+ wrong_dic[" ".join([row[-3].lower(), row[-1].lower()])] = 1
159
+ else:
160
+ wrong_dic[" ".join([row[-3].lower(), row[-1].lower()])] += 1
161
+ #print(wrong_dic)
162
+ target_func_num_dic = {}
163
+ for k in total_dic:
164
+ if k.split(" ")[0].lower() not in target_func_num_dic:
165
+ target_func_num_dic[k.split(" ")[0].lower()] = len(list(set(total_dic[k])))
166
+ else:
167
+ target_func_num_dic[k.split(" ")[0].lower()] += len(list(set(total_dic[k])))
168
+
169
+ with open(folder+"/err_percentage.csv", 'w', encoding='utf-8', newline = "") as f:
170
+ f_csv = csv.writer(f)
171
+ for k in target_func_num_dic:
172
+ #print(target_func_num_dic[k])
173
+ for err_type in ["err_v", "err_cs", "err_def"]:
174
+ if k + " " + err_type in wrong_dic.keys():
175
+
176
+ f_csv.writerow([k.replace("pulp", "ri5cy"), err_type, round(float(wrong_dic[k + " " + err_type]) / float(target_func_num_dic[k]), 3)])
177
+ else:
178
+ f_csv.writerow([k.replace("pulp", "ri5cy"), err_type, 0])
Scripts/Exp/Accuracy/calculate_purple.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, sys,string,re,glob
2
+
3
+ import json
4
+ import csv
5
+ import copy
6
+
7
+
8
+ import pathlib
9
+ import time
10
+
11
+ folder = str(pathlib.Path(__file__).parent.resolve())
12
+ #Total_encas
13
+
14
+
15
+
16
+ def calculate_template():
17
+ total_dic = {}
18
+ for line in open(folder+"/result.jsonl", 'r', encoding="utf-8"):
19
+ dic = json.loads(line)
20
+ if dic["Target"].lower() + " " + dic["Module"].lower() not in total_dic.keys():
21
+ total_dic[dic["Target"].lower() + " " + dic["Module"].lower()] = set()
22
+ total_dic[dic["Target"].lower() + " " + dic["Module"].lower()].add(dic["File"].strip() + " " + dic["Func"].strip() + " " + dic["Target"].strip())
23
+
24
+
25
+ res_dic = {}
26
+ with open(folder+"/Accurate_Func_Merged.csv", 'r', encoding='utf-8') as f:
27
+ f_csv = csv.reader(f)
28
+ for row in f_csv:
29
+ if " ".join([row[-1], row[0]]).lower() not in res_dic:
30
+ res_dic[" ".join([row[-1], row[0]]).lower()] = 1
31
+ else:
32
+ res_dic[" ".join([row[-1], row[0]]).lower()] += 1
33
+ with open(folder+"/fig8_purple.csv", 'w', encoding='utf-8', newline="") as f:
34
+ f_csv = csv.writer(f)
35
+ for k in res_dic.keys():
36
+ f_csv.writerow([k.split(' ')[0].replace("pulp", "ri5cy"), k.split(' ')[1], round(float(res_dic[k])/float(len(list(total_dic[k]))), 3)])
37
+
38
+
39
+
40
+ if __name__ == '__main__':
41
+ calculate_template()
42
+
Scripts/Exp/Accuracy/wrong_func_list_def.csv ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ RegisterInfo,eliminateFrameIndex,PULP,Allocation,Err_Def
2
+ RegisterInfo,getReservedRegs,PULP,Allocation,Err_Def
3
+ RegisterInfo,hasReservedSpillSlot,PULP,Allocation,Err_Def
4
+ AsmParser,addFenceArgOperands,PULP,Assembler,Err_Def
5
+ AsmParser,AsmParser,PULP,Assembler,Err_Def
6
+ AsmParser,classifySymbolRef,PULP,Assembler,Err_Def
7
+ AsmParser,defaultMaskRegOp,PULP,Assembler,Err_Def
8
+ AsmParser,getFeatureBits,PULP,Assembler,Err_Def
9
+ AsmParser,getRoundingMode,PULP,Assembler,Err_Def
10
+ AsmParser,isFenceArg,PULP,Assembler,Err_Def
11
+ AsmParser,isFRMArg,PULP,Assembler,Err_Def
12
+ AsmParser,MatchAndEmitInstruction,PULP,Assembler,Err_Def
13
+ AsmParser,matchRegisterNameHelper,PULP,Assembler,Err_Def
14
+ AsmParser,Operand2,PULP,Assembler,Err_Def
15
+ AsmParser,parseAtomicMemOp,PULP,Assembler,Err_Def
16
+ AsmParser,parseCallSymbol,PULP,Assembler,Err_Def
17
+ AsmParser,parseCSRSyestemRegister,PULP,Assembler,Err_Def
18
+ AsmParser,ParseDirective,PULP,Assembler,Err_Def
19
+ AsmParser,ParseInstruction,PULP,Assembler,Err_Def
20
+ AsmParser,parseJALOffset,PULP,Assembler,Err_Def
21
+ AsmParser,parseMaskReg,PULP,Assembler,Err_Def
22
+ AsmParser,parseMemOpBaseReg,PULP,Assembler,Err_Def
23
+ AsmParser,parseOperand,PULP,Assembler,Err_Def
24
+ AsmParser,parsePseudoJumpSymbol,PULP,Assembler,Err_Def
25
+ AsmParser,parseRegister2,PULP,Assembler,Err_Def
26
+ AsmParser,parseVTypeI,PULP,Assembler,Err_Def
27
+ AsmParser,print,PULP,Assembler,Err_Def
28
+ Disassembler,decodeFRMArg,PULP,Disassembler,Err_Def
29
+ Disassembler,DecodeGPRRegisterClass,PULP,Disassembler,Err_Def
30
+ Disassembler,decodeRVCInstrRdRs1UImm,PULP,Disassembler,Err_Def
31
+ Disassembler,decodeRVCInstrRdSImm,PULP,Disassembler,Err_Def
32
+ Disassembler,decodeRVCInstrSImm,PULP,Disassembler,Err_Def
33
+ Disassembler,getInstruction,PULP,Disassembler,Err_Def
34
+ AsmBackend,AsmBackend,PULP,Emission,Err_Def
35
+ AsmBackend,evaluateTargetFixup,PULP,Emission,Err_Def
36
+ AsmBackend,relaxInstruction,PULP,Emission,Err_Def
37
+ AsmBackend,requiresDiffExpressionRelocations,PULP,Emission,Err_Def
38
+ AsmBackend,shouldForceRelocation,PULP,Emission,Err_Def
39
+ AsmBackend,shouldInsertExtraNopBytesForCodeAlign,PULP,Emission,Err_Def
40
+ AsmBackend,shouldInsertFixupForCodeAlign,PULP,Emission,Err_Def
41
+ AsmBackend,willForceRelocations,PULP,Emission,Err_Def
42
+ BaseInfo,computeTargetABI,PULP,Emission,Err_Def
43
+ BaseInfo,validate,PULP,Emission,Err_Def
44
+ BaseInfo,VMTs,PULP,Emission,Err_Def
45
+ ELFStreamer,TargetELFStreamer,PULP,Emission,Err_Def
46
+ InstPrinter,printAtomicMemOp,PULP,Emission,Err_Def
47
+ InstPrinter,printCSRSystemRegister,PULP,Emission,Err_Def
48
+ InstPrinter,printFenceArg,PULP,Emission,Err_Def
49
+ InstPrinter,printFRMArg,PULP,Emission,Err_Def
50
+ InstPrinter,printInst,PULP,Emission,Err_Def
51
+ InstPrinter,printVMaskReg,PULP,Emission,Err_Def
52
+ InstPrinter,printVTypeI,PULP,Emission,Err_Def
53
+ MatInt,generateInstSeq,PULP,Emission,Err_Def
54
+ MatInt,getIntMatCost,PULP,Emission,Err_Def
55
+ MCCodeEmitter,encodeInstruction,PULP,Emission,Err_Def
56
+ MCCodeEmitter,getImmOpValue,PULP,Emission,Err_Def
57
+ MCCodeEmitter,getImmOpValueAsr1,PULP,Emission,Err_Def
58
+ MCCodeEmitter,getImmOpValueMinus1,PULP,Emission,Err_Def
59
+ MCExpr,evaluateAsConstant,PULP,Emission,Err_Def
60
+ MCExpr,getPCRelHiFixup,PULP,Emission,Err_Def
61
+ TargetStreamer,emitTargetAttributes,PULP,Emission,Err_Def
62
+ CleanupVSETVLI,runOnMachineBasicBlock,PULP,Optimization,Err_Def
63
+ ExpandAtomicPseudoInsts,expandMI,PULP,Optimization,Err_Def
64
+ ExpandPseudoInsts,expandMI,PULP,Optimization,Err_Def
65
+ ExpandSDMAInsts,expandMI,PULP,Optimization,Err_Def
66
+ ExpandSSRInsts,expandMI,PULP,Optimization,Err_Def
67
+ ExpandSSRInsts,runOnMachineFunction,PULP,Optimization,Err_Def
68
+ MergeBaseOffset,runOnMachineFunction,PULP,Optimization,Err_Def
69
+ PULPFixupHwLoops,runOnMachineFunction,PULP,Optimization,Err_Def
70
+ PULPHardwareLoops,checkForImmediate,PULP,Optimization,Err_Def
71
+ PULPHardwareLoops,convertToHardwareLoop,PULP,Optimization,Err_Def
72
+ PULPHardwareLoops,findInductionRegister,PULP,Optimization,Err_Def
73
+ PULPHardwareLoops,getLoopTripCount,PULP,Optimization,Err_Def
74
+ PULPHardwareLoops,isInvalidLoopOperation,PULP,Optimization,Err_Def
75
+ PULPHardwareLoops,runOnMachineFunction,PULP,Optimization,Err_Def
76
+ SNITCHFrepLoops,checkForImmediate,PULP,Optimization,Err_Def
77
+ SNITCHFrepLoops,containsInvalidInstruction,PULP,Optimization,Err_Def
78
+ SNITCHFrepLoops,convertToHardwareLoop,PULP,Optimization,Err_Def
79
+ SNITCHFrepLoops,findBranchInstruction,PULP,Optimization,Err_Def
80
+ SNITCHFrepLoops,findInductionRegister,PULP,Optimization,Err_Def
81
+ SNITCHFrepLoops,getLoopTripCount,PULP,Optimization,Err_Def
82
+ SNITCHFrepLoops,isInvalidLoopOperation,PULP,Optimization,Err_Def
83
+ SNITCHFrepLoops,runOnMachineFunction,PULP,Optimization,Err_Def
84
+ InstrInfo,buildOutlinedFrame,PULP,Scheduling,Err_Def
85
+ InstrInfo,copyPhysReg,PULP,Scheduling,Err_Def
86
+ InstrInfo,getInstSizeInBytes,PULP,Scheduling,Err_Def
87
+ InstrInfo,getOutliningCandidateInfo,PULP,Scheduling,Err_Def
88
+ InstrInfo,getOutliningType,PULP,Scheduling,Err_Def
89
+ InstrInfo,insertIndirectBranch,PULP,Scheduling,Err_Def
90
+ InstrInfo,insertOutlinedCall,PULP,Scheduling,Err_Def
91
+ InstrInfo,isAsCheapAsAMove,PULP,Scheduling,Err_Def
92
+ InstrInfo,isCopyInstrImpl,PULP,Scheduling,Err_Def
93
+ InstrInfo,movImm,PULP,Scheduling,Err_Def
94
+ InstrInfo,verifyInstruction,PULP,Scheduling,Err_Def
95
+ MachineFunctionInfo,getMoveF64FrameIndex,PULP,Scheduling,Err_Def
96
+ MachineFunctionInfo,useSaveRestoreLibCalls,PULP,Scheduling,Err_Def
97
+ Subtarget,initializeSubtargetDependencies,PULP,Scheduling,Err_Def
98
+ TargetMachine,addPreRegAlloc,PULP,Scheduling,Err_Def
99
+ TargetMachine,setTargetOptionsWithModuleMetadata,PULP,Scheduling,Err_Def
100
+ TargetMachine,TargetMachine,PULP,Scheduling,Err_Def
101
+ TargetObjectFile,getModuleMetadata,PULP,Scheduling,Err_Def
102
+ TargetObjectFile,isGlobalInSmallSection,PULP,Scheduling,Err_Def
103
+ TargetTransformInfo,getIntImmCost,PULP,Scheduling,Err_Def
104
+ TargetTransformInfo,getIntImmCostInst,PULP,Scheduling,Err_Def
105
+ FrameLowering,canUseAsEpilogue,PULP,Selection,Err_Def
106
+ FrameLowering,canUseAsPrologue,PULP,Selection,Err_Def
107
+ FrameLowering,determineCalleeSaves,PULP,Selection,Err_Def
108
+ FrameLowering,emitEpilogue,PULP,Selection,Err_Def
109
+ FrameLowering,emitPrologue,PULP,Selection,Err_Def
110
+ FrameLowering,getFrameIndexReference,PULP,Selection,Err_Def
111
+ FrameLowering,restoreCalleeSavedRegisters,PULP,Selection,Err_Def
112
+ FrameLowering,spillCalleeSavedRegisters,PULP,Selection,Err_Def
113
+ ISelDAGtoDAG,MatchSLLIUW,PULP,Selection,Err_Def
114
+ ISelDAGtoDAG,MatchSRLIUW,PULP,Selection,Err_Def
115
+ ISelDAGtoDAG,PostprocessISelDAG,PULP,Selection,Err_Def
116
+ ISelDAGtoDAG,Select,PULP,Selection,Err_Def
117
+ ISelDAGtoDAG,selectVLOp,PULP,Selection,Err_Def
118
+ ISelDAGtoDAG,selectVSplat,PULP,Selection,Err_Def
119
+ ISelDAGtoDAG,selectVSplatSimm5,PULP,Selection,Err_Def
120
+ ISelDAGtoDAG,selectVSplatUimm5,PULP,Selection,Err_Def
121
+ ISelLowering,analyzeInputArgs,PULP,Selection,Err_Def
122
+ ISelLowering,analyzeOutputArgs,PULP,Selection,Err_Def
123
+ ISelLowering,CanLowerReturn,PULP,Selection,Err_Def
124
+ ISelLowering,computeKnownBitsForTargetNode,PULP,Selection,Err_Def
125
+ ISelLowering,ComputeNumSignBitsForTargetNode,PULP,Selection,Err_Def
126
+ ISelLowering,decomposeMulByConstant,PULP,Selection,Err_Def
127
+ ISelLowering,EmitInstrWithCustomInserter,PULP,Selection,Err_Def
128
+ ISelLowering,emitLeadingFence,PULP,Selection,Err_Def
129
+ ISelLowering,emitMaskedAtomicCmpXchgIntrinsic,PULP,Selection,Err_Def
130
+ ISelLowering,emitMaskedAtomicRMWIntrinsic,PULP,Selection,Err_Def
131
+ ISelLowering,emitTrailingFence,PULP,Selection,Err_Def
132
+ ISelLowering,getAddr,PULP,Selection,Err_Def
133
+ ISelLowering,getPostIndexedAddressParts,PULP,Selection,Err_Def
134
+ ISelLowering,getRegForInlineAsmConstraint,PULP,Selection,Err_Def
135
+ ISelLowering,getRegisterByName,PULP,Selection,Err_Def
136
+ ISelLowering,getStaticTLSAddr,PULP,Selection,Err_Def
137
+ ISelLowering,getTgtMemIntrinsic,PULP,Selection,Err_Def
138
+ ISelLowering,isDesirableToCommuteWithShift,PULP,Selection,Err_Def
139
+ ISelLowering,isEligibleForTailCallOptimization,PULP,Selection,Err_Def
140
+ ISelLowering,isFPImmLegal,PULP,Selection,Err_Def
141
+ ISelLowering,LowerCall,PULP,Selection,Err_Def
142
+ ISelLowering,lowerEXTRACT_VECTOR_ELT,PULP,Selection,Err_Def
143
+ ISelLowering,LowerFormalArguments,PULP,Selection,Err_Def
144
+ ISelLowering,lowerINSERT_VECTOR_ELT,PULP,Selection,Err_Def
145
+ ISelLowering,LowerINTRINSIC_W_CHAIN,PULP,Selection,Err_Def
146
+ ISelLowering,LowerINTRINSIC_WO_CHAIN,PULP,Selection,Err_Def
147
+ ISelLowering,LowerOperation,PULP,Selection,Err_Def
148
+ ISelLowering,LowerReturn,PULP,Selection,Err_Def
149
+ ISelLowering,lowerShiftLeftParts,PULP,Selection,Err_Def
150
+ ISelLowering,lowerShiftRightParts,PULP,Selection,Err_Def
151
+ ISelLowering,lowerSPLATVECTOR,PULP,Selection,Err_Def
152
+ ISelLowering,lowerVectorMaskExt,PULP,Selection,Err_Def
153
+ ISelLowering,lowerVectorMaskTrunc,PULP,Selection,Err_Def
154
+ ISelLowering,PerformDAGCombine,PULP,Selection,Err_Def
155
+ ISelLowering,ReplaceNodeResults,PULP,Selection,Err_Def
156
+ ISelLowering,shouldExtendTypeInLibCall,PULP,Selection,Err_Def
157
+ ISelLowering,TargetLowering,PULP,Selection,Err_Def
158
+ ISelLowering,targetShrinkDemandedConstant,PULP,Selection,Err_Def
159
+ ISelLowering,validateCCReservedRegs,PULP,Selection,Err_Def
160
+ MCInstLower,lowerMachineInstrToMCInst,PULP,Selection,Err_Def
161
+ RegisterInfo,eliminateFrameIndex,RISCV,Allocation,Err_Def
162
+ RegisterInfo,hasReservedSpillSlot,RISCV,Allocation,Err_Def
163
+ AsmParser,addFenceArgOperands,RISCV,Assembler,Err_Def
164
+ AsmParser,AsmParser,RISCV,Assembler,Err_Def
165
+ AsmParser,classifySymbolRef,RISCV,Assembler,Err_Def
166
+ AsmParser,defaultMaskRegOp,RISCV,Assembler,Err_Def
167
+ AsmParser,getFeatureBits,RISCV,Assembler,Err_Def
168
+ AsmParser,getRoundingMode,RISCV,Assembler,Err_Def
169
+ AsmParser,isFenceArg,RISCV,Assembler,Err_Def
170
+ AsmParser,isFRMArg,RISCV,Assembler,Err_Def
171
+ AsmParser,MatchAndEmitInstruction,RISCV,Assembler,Err_Def
172
+ AsmParser,matchRegisterNameHelper,RISCV,Assembler,Err_Def
173
+ AsmParser,Operand2,RISCV,Assembler,Err_Def
174
+ AsmParser,parseAtomicMemOp,RISCV,Assembler,Err_Def
175
+ AsmParser,parseCallSymbol,RISCV,Assembler,Err_Def
176
+ AsmParser,parseCSRSyestemRegister,RISCV,Assembler,Err_Def
177
+ AsmParser,ParseDirective,RISCV,Assembler,Err_Def
178
+ AsmParser,ParseInstruction,RISCV,Assembler,Err_Def
179
+ AsmParser,parseJALOffset,RISCV,Assembler,Err_Def
180
+ AsmParser,parseMaskReg,RISCV,Assembler,Err_Def
181
+ AsmParser,parsePseudoJumpSymbol,RISCV,Assembler,Err_Def
182
+ AsmParser,parseRegister2,RISCV,Assembler,Err_Def
183
+ AsmParser,parseVTypeI,RISCV,Assembler,Err_Def
184
+ AsmParser,print,RISCV,Assembler,Err_Def
185
+ Disassembler,decodeFRMArg,RISCV,Disassembler,Err_Def
186
+ Disassembler,DecodeGPRRegisterClass,RISCV,Disassembler,Err_Def
187
+ Disassembler,decodeRVCInstrRdRs1UImm,RISCV,Disassembler,Err_Def
188
+ Disassembler,decodeRVCInstrRdSImm,RISCV,Disassembler,Err_Def
189
+ Disassembler,decodeRVCInstrSImm,RISCV,Disassembler,Err_Def
190
+ Disassembler,getInstruction,RISCV,Disassembler,Err_Def
191
+ AsmBackend,AsmBackend,RISCV,Emission,Err_Def
192
+ AsmBackend,evaluateTargetFixup,RISCV,Emission,Err_Def
193
+ AsmBackend,relaxInstruction,RISCV,Emission,Err_Def
194
+ AsmBackend,requiresDiffExpressionRelocations,RISCV,Emission,Err_Def
195
+ AsmBackend,shouldForceRelocation,RISCV,Emission,Err_Def
196
+ AsmBackend,shouldInsertExtraNopBytesForCodeAlign,RISCV,Emission,Err_Def
197
+ AsmBackend,shouldInsertFixupForCodeAlign,RISCV,Emission,Err_Def
198
+ AsmBackend,willForceRelocations,RISCV,Emission,Err_Def
199
+ BaseInfo,computeTargetABI,RISCV,Emission,Err_Def
200
+ BaseInfo,validate,RISCV,Emission,Err_Def
201
+ BaseInfo,VMTs,RISCV,Emission,Err_Def
202
+ ELFStreamer,TargetELFStreamer,RISCV,Emission,Err_Def
203
+ InstPrinter,printAtomicMemOp,RISCV,Emission,Err_Def
204
+ InstPrinter,printCSRSystemRegister,RISCV,Emission,Err_Def
205
+ InstPrinter,printFenceArg,RISCV,Emission,Err_Def
206
+ InstPrinter,printFRMArg,RISCV,Emission,Err_Def
207
+ InstPrinter,printInst,RISCV,Emission,Err_Def
208
+ InstPrinter,printVMaskReg,RISCV,Emission,Err_Def
209
+ InstPrinter,printVTypeI,RISCV,Emission,Err_Def
210
+ MatInt,generateInstSeq,RISCV,Emission,Err_Def
211
+ MatInt,getIntMatCost,RISCV,Emission,Err_Def
212
+ MCCodeEmitter,encodeInstruction,RISCV,Emission,Err_Def
213
+ MCCodeEmitter,getImmOpValue,RISCV,Emission,Err_Def
214
+ MCCodeEmitter,getImmOpValueAsr1,RISCV,Emission,Err_Def
215
+ MCExpr,evaluateAsConstant,RISCV,Emission,Err_Def
216
+ MCExpr,getPCRelHiFixup,RISCV,Emission,Err_Def
217
+ TargetStreamer,emitTargetAttributes,RISCV,Emission,Err_Def
218
+ CleanupVSETVLI,runOnMachineBasicBlock,RISCV,Optimization,Err_Def
219
+ ExpandAtomicPseudoInsts,expandMI,RISCV,Optimization,Err_Def
220
+ ExpandPseudoInsts,expandMI,RISCV,Optimization,Err_Def
221
+ MergeBaseOffset,runOnMachineFunction,RISCV,Optimization,Err_Def
222
+ InstrInfo,buildOutlinedFrame,RISCV,Scheduling,Err_Def
223
+ InstrInfo,copyPhysReg,RISCV,Scheduling,Err_Def
224
+ InstrInfo,getInstSizeInBytes,RISCV,Scheduling,Err_Def
225
+ InstrInfo,getOutliningCandidateInfo,RISCV,Scheduling,Err_Def
226
+ InstrInfo,getOutliningType,RISCV,Scheduling,Err_Def
227
+ InstrInfo,insertIndirectBranch,RISCV,Scheduling,Err_Def
228
+ InstrInfo,insertOutlinedCall,RISCV,Scheduling,Err_Def
229
+ InstrInfo,isAsCheapAsAMove,RISCV,Scheduling,Err_Def
230
+ InstrInfo,isCopyInstrImpl,RISCV,Scheduling,Err_Def
231
+ InstrInfo,movImm,RISCV,Scheduling,Err_Def
232
+ InstrInfo,verifyInstruction,RISCV,Scheduling,Err_Def
233
+ MachineFunctionInfo,getMoveF64FrameIndex,RISCV,Scheduling,Err_Def
234
+ MachineFunctionInfo,useSaveRestoreLibCalls,RISCV,Scheduling,Err_Def
235
+ Subtarget,initializeSubtargetDependencies,RISCV,Scheduling,Err_Def
236
+ TargetMachine,addPreRegAlloc,RISCV,Scheduling,Err_Def
237
+ TargetMachine,TargetMachine,RISCV,Scheduling,Err_Def
238
+ TargetObjectFile,getModuleMetadata,RISCV,Scheduling,Err_Def
239
+ TargetObjectFile,isGlobalInSmallSection,RISCV,Scheduling,Err_Def
240
+ TargetTransformInfo,getIntImmCost,RISCV,Scheduling,Err_Def
241
+ TargetTransformInfo,getIntImmCostInst,RISCV,Scheduling,Err_Def
242
+ FrameLowering,canUseAsEpilogue,RISCV,Selection,Err_Def
243
+ FrameLowering,canUseAsPrologue,RISCV,Selection,Err_Def
244
+ FrameLowering,determineCalleeSaves,RISCV,Selection,Err_Def
245
+ FrameLowering,emitEpilogue,RISCV,Selection,Err_Def
246
+ FrameLowering,emitPrologue,RISCV,Selection,Err_Def
247
+ FrameLowering,getFrameIndexReference,RISCV,Selection,Err_Def
248
+ FrameLowering,restoreCalleeSavedRegisters,RISCV,Selection,Err_Def
249
+ FrameLowering,spillCalleeSavedRegisters,RISCV,Selection,Err_Def
250
+ ISelDAGtoDAG,MatchSLLIUW,RISCV,Selection,Err_Def
251
+ ISelDAGtoDAG,MatchSRLIUW,RISCV,Selection,Err_Def
252
+ ISelDAGtoDAG,PostprocessISelDAG,RISCV,Selection,Err_Def
253
+ ISelDAGtoDAG,Select,RISCV,Selection,Err_Def
254
+ ISelDAGtoDAG,selectVLOp,RISCV,Selection,Err_Def
255
+ ISelDAGtoDAG,selectVSplat,RISCV,Selection,Err_Def
256
+ ISelDAGtoDAG,selectVSplatSimm5,RISCV,Selection,Err_Def
257
+ ISelDAGtoDAG,selectVSplatUimm5,RISCV,Selection,Err_Def
258
+ ISelLowering,analyzeInputArgs,RISCV,Selection,Err_Def
259
+ ISelLowering,analyzeOutputArgs,RISCV,Selection,Err_Def
260
+ ISelLowering,CanLowerReturn,RISCV,Selection,Err_Def
261
+ ISelLowering,computeKnownBitsForTargetNode,RISCV,Selection,Err_Def
262
+ ISelLowering,ComputeNumSignBitsForTargetNode,RISCV,Selection,Err_Def
263
+ ISelLowering,decomposeMulByConstant,RISCV,Selection,Err_Def
264
+ ISelLowering,EmitInstrWithCustomInserter,RISCV,Selection,Err_Def
265
+ ISelLowering,emitLeadingFence,RISCV,Selection,Err_Def
266
+ ISelLowering,emitMaskedAtomicCmpXchgIntrinsic,RISCV,Selection,Err_Def
267
+ ISelLowering,emitMaskedAtomicRMWIntrinsic,RISCV,Selection,Err_Def
268
+ ISelLowering,emitTrailingFence,RISCV,Selection,Err_Def
269
+ ISelLowering,getAddr,RISCV,Selection,Err_Def
270
+ ISelLowering,getRegForInlineAsmConstraint,RISCV,Selection,Err_Def
271
+ ISelLowering,getRegisterByName,RISCV,Selection,Err_Def
272
+ ISelLowering,getStaticTLSAddr,RISCV,Selection,Err_Def
273
+ ISelLowering,getTgtMemIntrinsic,RISCV,Selection,Err_Def
274
+ ISelLowering,isDesirableToCommuteWithShift,RISCV,Selection,Err_Def
275
+ ISelLowering,isEligibleForTailCallOptimization,RISCV,Selection,Err_Def
276
+ ISelLowering,isFPImmLegal,RISCV,Selection,Err_Def
277
+ ISelLowering,LowerCall,RISCV,Selection,Err_Def
278
+ ISelLowering,lowerEXTRACT_VECTOR_ELT,RISCV,Selection,Err_Def
279
+ ISelLowering,LowerFormalArguments,RISCV,Selection,Err_Def
280
+ ISelLowering,lowerINSERT_VECTOR_ELT,RISCV,Selection,Err_Def
281
+ ISelLowering,LowerINTRINSIC_W_CHAIN,RISCV,Selection,Err_Def
282
+ ISelLowering,LowerINTRINSIC_WO_CHAIN,RISCV,Selection,Err_Def
283
+ ISelLowering,LowerOperation,RISCV,Selection,Err_Def
284
+ ISelLowering,LowerReturn,RISCV,Selection,Err_Def
285
+ ISelLowering,lowerShiftLeftParts,RISCV,Selection,Err_Def
286
+ ISelLowering,lowerShiftRightParts,RISCV,Selection,Err_Def
287
+ ISelLowering,lowerSPLATVECTOR,RISCV,Selection,Err_Def
288
+ ISelLowering,lowerVectorMaskExt,RISCV,Selection,Err_Def
289
+ ISelLowering,lowerVectorMaskTrunc,RISCV,Selection,Err_Def
290
+ ISelLowering,PerformDAGCombine,RISCV,Selection,Err_Def
291
+ ISelLowering,ReplaceNodeResults,RISCV,Selection,Err_Def
292
+ ISelLowering,shouldExtendTypeInLibCall,RISCV,Selection,Err_Def
293
+ ISelLowering,TargetLowering,RISCV,Selection,Err_Def
294
+ ISelLowering,targetShrinkDemandedConstant,RISCV,Selection,Err_Def
295
+ ISelLowering,validateCCReservedRegs,RISCV,Selection,Err_Def
296
+ MCInstLower,lowerMachineInstrToMCInst,RISCV,Selection,Err_Def
297
+ RegisterInfo,eliminateCallFramePseudoInstr,XCore,Allocation,Err_Def
298
+ RegisterInfo,eliminateFrameIndex,XCore,Allocation,Err_Def
299
+ RegisterInfo,getCalleeSavedRegs,XCore,Allocation,Err_Def
300
+ AsmPrinter,AsmPrinter,XCore,Assembler,Err_Def
301
+ AsmPrinter,EmitBasicBlockStart,XCore,Assembler,Err_Def
302
+ AsmPrinter,EmitConstantPool,XCore,Assembler,Err_Def
303
+ AsmPrinter,EmitEndOfAsmFile,XCore,Assembler,Err_Def
304
+ AsmPrinter,EmitFunctionEntryLabel,XCore,Assembler,Err_Def
305
+ AsmPrinter,EmitGlobalVariable,XCore,Assembler,Err_Def
306
+ AsmPrinter,EmitInstruction,XCore,Assembler,Err_Def
307
+ AsmPrinter,EmitStartOfAsmFile,XCore,Assembler,Err_Def
308
+ AsmPrinter,printInlineJT,XCore,Assembler,Err_Def
309
+ AsmPrinter,printInlineJT32,XCore,Assembler,Err_Def
310
+ AsmPrinter,PrintSpecial,XCore,Assembler,Err_Def
311
+ AsmPrinter,runOnMachineFunction,XCore,Assembler,Err_Def
312
+ FrameToArgsOffsetElim,runOnMachineFunction,XCore,Optimization,Err_Def
313
+ LoopMetadataLowering,runOnFunction,XCore,Optimization,Err_Def
314
+ SimpleBranchOpt,runOnMachineFunction,XCore,Optimization,Err_Def
315
+ StackAnalysisPrepare,runOnFunction,XCore,Optimization,Err_Def
316
+ StackUsage,runOnMachineFunction,XCore,Optimization,Err_Def
317
+ InstrInfo,analyzeBranch,XCore,Scheduling,Err_Def
318
+ InstrInfo,copyPhysReg,XCore,Scheduling,Err_Def
319
+ InstrInfo,GetInstSizeInBytes,XCore,Scheduling,Err_Def
320
+ InstrInfo,insertBranch,XCore,Scheduling,Err_Def
321
+ MachineFunctionInfo,~FunctionInfo,XCore,Scheduling,Err_Def
322
+ MachineFunctionInfo,Call,XCore,Scheduling,Err_Def
323
+ MachineFunctionInfo,ExternalSymbolCall,XCore,Scheduling,Err_Def
324
+ MachineFunctionInfo,FunctionCall,XCore,Scheduling,Err_Def
325
+ MachineFunctionInfo,FunctionInfo,XCore,Scheduling,Err_Def
326
+ MachineFunctionInfo,FunctionInfo2,XCore,Scheduling,Err_Def
327
+ TargetObjectFile,getExplicitSectionGlobal,XCore,Scheduling,Err_Def
328
+ TargetObjectFile,getSectionForConstant,XCore,Scheduling,Err_Def
329
+ TargetObjectFile,Initialize,XCore,Scheduling,Err_Def
330
+ TargetObjectFile,SelectSectionForGlobal,XCore,Scheduling,Err_Def
331
+ FrameLowering,emitEpilogue,XCore,Selection,Err_Def
332
+ FrameLowering,emitPrologue,XCore,Selection,Err_Def
333
+ FrameLowering,processFunctionBeforeCalleeSavedScan,XCore,Selection,Err_Def
334
+ FrameLowering,restoreCalleeSavedRegisters,XCore,Selection,Err_Def
335
+ FrameLowering,spillCalleeSavedRegisters,XCore,Selection,Err_Def
336
+ ISelDAGToDAG,immBitp,XCore,Selection,Err_Def
337
+ ISelDAGToDAG,immMskBitp,XCore,Selection,Err_Def
338
+ ISelDAGToDAG,Select,XCore,Selection,Err_Def
339
+ ISelDAGToDAG,SelectInlineAsmMemoryOperand,XCore,Selection,Err_Def
340
+ ISelLowering,computeMaskedBitsForTargetNode,XCore,Selection,Err_Def
341
+ ISelLowering,ExpandADDSUB,XCore,Selection,Err_Def
342
+ ISelLowering,isLegalAddImmediate,XCore,Selection,Err_Def
343
+ ISelLowering,isLegalAddressingMode,XCore,Selection,Err_Def
344
+ ISelLowering,LowerBR_JT,XCore,Selection,Err_Def
345
+ ISelLowering,LowerCall,XCore,Selection,Err_Def
346
+ ISelLowering,LowerDYNAMIC_STACKALLOC,XCore,Selection,Err_Def
347
+ ISelLowering,LowerEH_RETURN,XCore,Selection,Err_Def
348
+ ISelLowering,LowerFormalArguments,XCore,Selection,Err_Def
349
+ ISelLowering,LowerFRAME_TO_ARGS_OFFSET,XCore,Selection,Err_Def
350
+ ISelLowering,LowerFRAMEADDR,XCore,Selection,Err_Def
351
+ ISelLowering,LowerGlobalAddress,XCore,Selection,Err_Def
352
+ ISelLowering,LowerGlobalTLSAddress,XCore,Selection,Err_Def
353
+ ISelLowering,LowerINIT_TRAMPOLINE,XCore,Selection,Err_Def
354
+ ISelLowering,LowerINTRINSIC_WO_CHAIN,XCore,Selection,Err_Def
355
+ ISelLowering,LowerLOAD,XCore,Selection,Err_Def
356
+ ISelLowering,LowerOperation,XCore,Selection,Err_Def
357
+ ISelLowering,LowerReturn,XCore,Selection,Err_Def
358
+ ISelLowering,LowerRETURNADDR,XCore,Selection,Err_Def
359
+ ISelLowering,LowerSMUL_LOHI,XCore,Selection,Err_Def
360
+ ISelLowering,LowerSTACKSAVE,XCore,Selection,Err_Def
361
+ ISelLowering,LowerSTORE,XCore,Selection,Err_Def
362
+ ISelLowering,LowerUMUL_LOHI,XCore,Selection,Err_Def
363
+ ISelLowering,PerformDAGCombine,XCore,Selection,Err_Def
364
+ ISelLowering,ReplaceNodeResults,XCore,Selection,Err_Def
365
+ ISelLowering,TargetLowering,XCore,Selection,Err_Def
366
+ SelectionDAGInfo,EmitTargetCodeForMemcpy,XCore,Selection,Err_Def
Scripts/Exp/Correction/Correction_Time.xlsx ADDED
Binary file (46.2 kB). View file
 
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterBankInfo/RegisterBankInfo.cpp ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ MipsRegisterBankInfo::MipsRegisterBankInfo(const TargetRegisterInfo &TRI) : MipsGenRegisterBankInfo() {
2
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/RegisterInfo.cpp ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ MipsRegisterInfo::MipsRegisterInfo() : MipsGenRegisterInfo(Mips::RA) {
2
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/eliminateFrameIndex.cpp ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ void MipsRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS) const {
2
+ MachineInstr &MI = *II;
3
+ MachineFunction &MF = *MI.getParent()->getParent();
4
+ LLVM_DEBUG(errs() << "\nFunction : " << MF.getName() << "\n"; errs() << "<--------->\n" << MI);
5
+ int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
6
+ uint64_t stackSize = MF.getFrameInfo().getStackSize();
7
+ int64_t spOffset = MF.getFrameInfo().getObjectOffset(FrameIndex);
8
+ LLVM_DEBUG(errs() << "FrameIndex : " << FrameIndex << "\n" << "spOffset : " << spOffset << "\n" << "stackSize : " << stackSize << "\n" << "alignment : " << DebugStr(MF.getFrameInfo().getObjectAlign(FrameIndex)) << "\n");
9
+ eliminateFI(MI, FIOperandNum, FrameIndex, stackSize, spOffset);
10
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getCallPreservedMask.cpp ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const uint32_t *MipsRegisterInfo::getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const {
2
+ const MipsSubtarget &Subtarget = MF.getSubtarget<MipsSubtarget>();
3
+ if (Subtarget.isSingleFloat())
4
+ return CSR_SingleFloatOnly_RegMask;
5
+ if (Subtarget.isABI_N64())
6
+ return CSR_N64_RegMask;
7
+ if (Subtarget.isABI_N32())
8
+ return CSR_N32_RegMask;
9
+ if (Subtarget.isFP64bit())
10
+ return CSR_O32_FP64_RegMask;
11
+ if (Subtarget.isFPXX())
12
+ return CSR_O32_FPXX_RegMask;
13
+ return CSR_O32_RegMask;
14
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getCalleeSavedRegs.cpp ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const MCPhysReg *MipsRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
2
+ const MipsSubtarget &Subtarget = MF->getSubtarget<MipsSubtarget>();
3
+ const Function &F = MF->getFunction();
4
+ if (F.hasFnAttribute("interrupt")) {
5
+ if (Subtarget.hasMips64())
6
+ return Subtarget.hasMips64r6() ? CSR_Interrupt_64R6_SaveList : CSR_Interrupt_64_SaveList;
7
+ else
8
+ return Subtarget.hasMips32r6() ? CSR_Interrupt_32R6_SaveList : CSR_Interrupt_32_SaveList;
9
+ }
10
+ if (Subtarget.isSingleFloat())
11
+ return CSR_SingleFloatOnly_SaveList;
12
+ if (Subtarget.isABI_N64())
13
+ return CSR_N64_SaveList;
14
+ if (Subtarget.isABI_N32())
15
+ return CSR_N32_SaveList;
16
+ if (Subtarget.isFP64bit())
17
+ return CSR_O32_FP64_SaveList;
18
+ if (Subtarget.isFPXX())
19
+ return CSR_O32_FPXX_SaveList;
20
+ return CSR_O32_SaveList;
21
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getFrameRegister.cpp ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ Register MipsRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
2
+ const MipsSubtarget &Subtarget = MF.getSubtarget<MipsSubtarget>();
3
+ const TargetFrameLowering *TFI = Subtarget.getFrameLowering();
4
+ bool IsN64 = static_cast<const MipsTargetMachine &>(MF.getTarget()).getABI().IsN64();
5
+ if (Subtarget.inMips16Mode())
6
+ return TFI->hasFP(MF) ? Mips::S0 : Mips::SP;
7
+ else
8
+ return TFI->hasFP(MF) ? (IsN64 ? Mips::FP_64 : Mips::FP) : (IsN64 ? Mips::SP_64 : Mips::SP);
9
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getNoPreservedMask.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getPointerRegClass.cpp ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const TargetRegisterClass *MipsRegisterInfo::getPointerRegClass(const MachineFunction &MF, unsigned Kind) const {
2
+ MipsABIInfo ABI = MF.getSubtarget<MipsSubtarget>().getABI();
3
+ MipsPtrClass PtrClassKind = static_cast<MipsPtrClass>(Kind);
4
+ switch (PtrClassKind) {
5
+ case MipsPtrClass::Default:
6
+ return ABI.ArePtrs64bit() ? &Mips::GPR64RegClass : &Mips::GPR32RegClass;
7
+ case MipsPtrClass::GPR16MM:
8
+ return &Mips::GPRMM16RegClass;
9
+ case MipsPtrClass::StackPointer:
10
+ return ABI.ArePtrs64bit() ? &Mips::SP64RegClass : &Mips::SP32RegClass;
11
+ case MipsPtrClass::GlobalPointer:
12
+ return ABI.ArePtrs64bit() ? &Mips::GP64RegClass : &Mips::GP32RegClass;
13
+ }
14
+ llvm_unreachable("Unknown pointer kind");
15
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/getReservedRegs.cpp ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ BitVector MipsRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
2
+ static const MCPhysReg ReservedGPR32[] = {
3
+ Mips::ZERO, Mips::K0, Mips::K1, Mips::SP
4
+ };
5
+ static const MCPhysReg ReservedGPR64[] = {
6
+ Mips::ZERO_64, Mips::K0_64, Mips::K1_64, Mips::SP_64
7
+ };
8
+ BitVector Reserved(getNumRegs());
9
+ const MipsSubtarget &Subtarget = MF.getSubtarget<MipsSubtarget>();
10
+ for (unsigned I = 0; I < array_lengthof(ReservedGPR32); ++I)
11
+ Reserved.set(ReservedGPR32[I]);
12
+ if (Subtarget.isTargetNaCl()) {
13
+ Reserved.set(Mips::T6);
14
+ Reserved.set(Mips::T7);
15
+ Reserved.set(Mips::T8);
16
+ }
17
+ for (unsigned I = 0; I < array_lengthof(ReservedGPR64); ++I)
18
+ Reserved.set(ReservedGPR64[I]);
19
+ if (!Subtarget.isABICalls()) {
20
+ Reserved.set(Mips::GP);
21
+ Reserved.set(Mips::GP_64);
22
+ }
23
+ if (Subtarget.isFP64bit()) {
24
+ for (MCPhysReg Reg : Mips::AFGR64RegClass)
25
+ Reserved.set(Reg);
26
+ }
27
+ else {
28
+ for (MCPhysReg Reg : Mips::FGR64RegClass)
29
+ Reserved.set(Reg);
30
+ }
31
+ if (Subtarget.getFrameLowering()->hasFP(MF)) {
32
+ if (Subtarget.inMips16Mode())
33
+ Reserved.set(Mips::S0);
34
+ else {
35
+ Reserved.set(Mips::FP);
36
+ Reserved.set(Mips::FP_64);
37
+ if (needsStackRealignment(MF) && MF.getFrameInfo().hasVarSizedObjects()) {
38
+ Reserved.set(Mips::S7);
39
+ Reserved.set(Mips::S7_64);
40
+ }
41
+ }
42
+ }
43
+ Reserved.set(Mips::HWR29);
44
+ Reserved.set(Mips::DSPPos);
45
+ Reserved.set(Mips::DSPSCount);
46
+ Reserved.set(Mips::DSPCarry);
47
+ Reserved.set(Mips::DSPEFI);
48
+ Reserved.set(Mips::DSPOutFlag);
49
+ for (MCPhysReg Reg : Mips::MSACtrlRegClass)
50
+ Reserved.set(Reg);
51
+ if (Subtarget.inMips16Mode()) {
52
+ const MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
53
+ Reserved.set(Mips::RA);
54
+ Reserved.set(Mips::RA_64);
55
+ Reserved.set(Mips::T0);
56
+ Reserved.set(Mips::T1);
57
+ if (MF.getFunction().hasFnAttribute("saveS2") || MipsFI->hasSaveS2())
58
+ Reserved.set(Mips::S2);
59
+ }
60
+ if (Subtarget.useSmallSection()) {
61
+ Reserved.set(Mips::GP);
62
+ Reserved.set(Mips::GP_64);
63
+ }
64
+ return Reserved;
65
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/hasReservedSpillSlot.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/isAsmClobberable.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/isConstantPhysReg.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/requiresFrameIndexScavenging.cpp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ bool Mips16RegisterInfo::requiresFrameIndexScavenging(const MachineFunction &MF) const {
2
+ return false;
3
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Allocation/RegisterInfo/requiresRegisterScavenging.cpp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ bool MipsRegisterInfo::requiresRegisterScavenging(const MachineFunction &MF) const {
2
+ return true;
3
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/AsmParser.cpp ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MipsAsmParser(const MCSubtargetInfo &sti, MCAsmParser &parser, const MCInstrInfo &MII, const MCTargetOptions &Options) : MCTargetAsmParser(Options, sti, MII), ABI(MipsABIInfo::computeTargetABI(Triple(sti.getTargetTriple()), sti.getCPU(), Options)) {
2
+ MCAsmParserExtension::Initialize(parser);
3
+ parser.addAliasForDirective(".asciiz", ".asciz");
4
+ parser.addAliasForDirective(".hword", ".2byte");
5
+ parser.addAliasForDirective(".word", ".4byte");
6
+ parser.addAliasForDirective(".dword", ".8byte");
7
+ setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
8
+ AssemblerOptions.push_back(std::make_unique<MipsAssemblerOptions>(getSTI().getFeatureBits()));
9
+ AssemblerOptions.push_back(std::make_unique<MipsAssemblerOptions>(getSTI().getFeatureBits()));
10
+ getTargetStreamer().updateABIInfo(*this);
11
+ if (!isABI_O32() && !useOddSPReg() != 0)
12
+ report_fatal_error("-mno-odd-spreg requires the O32 ABI");
13
+ CurrentFn = nullptr;
14
+ IsPicEnabled = getContext().getObjectFileInfo()->isPositionIndependent();
15
+ IsCpRestoreSet = false;
16
+ CpRestoreOffset = -1;
17
+ GPReg = ABI.GetGlobalPtr();
18
+ const Triple &TheTriple = sti.getTargetTriple();
19
+ IsLittleEndian = TheTriple.isLittleEndian();
20
+ if (getSTI().getCPU() == "mips64r6" && inMicroMipsMode())
21
+ report_fatal_error("microMIPS64R6 is not supported", false);
22
+ if (!isABI_O32() && inMicroMipsMode())
23
+ report_fatal_error("microMIPS64 is not supported", false);
24
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/KindTy.cpp ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ enum KindTy {
2
+ k_Immediate,
3
+ k_Memory,
4
+ k_RegisterIndex,
5
+ k_Token,
6
+ k_RegList,
7
+ } Kind;
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/LLVMInitializeAsmParser.cpp ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsAsmParser() {
2
+ RegisterMCAsmParser<MipsAsmParser> X(getTheMipsTarget());
3
+ RegisterMCAsmParser<MipsAsmParser> Y(getTheMipselTarget());
4
+ RegisterMCAsmParser<MipsAsmParser> A(getTheMips64Target());
5
+ RegisterMCAsmParser<MipsAsmParser> B(getTheMips64elTarget());
6
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/MatchAndEmitInstruction.cpp ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ bool MipsAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, OperandVector &Operands, MCStreamer &Out, uint64_t &ErrorInfo, bool MatchingInlineAsm) {
2
+ MCInst Inst;
3
+ unsigned MatchResult = MatchInstructionImpl(Operands, Inst, ErrorInfo, MatchingInlineAsm);
4
+ switch (MatchResult) {
5
+ case Match_Success:
6
+ if (processInstruction(Inst, IDLoc, Out, STI))
7
+ return true;
8
+ return false;
9
+ case Match_MissingFeature:
10
+ Error(IDLoc, "instruction requires a CPU feature not currently enabled");
11
+ return true;
12
+ case Match_InvalidOperand: {
13
+ SMLoc ErrorLoc = IDLoc;
14
+ if (ErrorInfo != ~0ULL) {
15
+ if (ErrorInfo >= Operands.size())
16
+ return Error(IDLoc, "too few operands for instruction");
17
+ ErrorLoc = Operands[ErrorInfo]->getStartLoc();
18
+ if (ErrorLoc == SMLoc())
19
+ ErrorLoc = IDLoc;
20
+ }
21
+ return Error(ErrorLoc, "invalid operand for instruction");
22
+ }
23
+ case Match_NonZeroOperandForSync:
24
+ return Error(IDLoc, "s-type must be zero or unspecified for pre-MIPS32 ISAs");
25
+ case Match_NonZeroOperandForMTCX:
26
+ return Error(IDLoc, "selector must be zero for pre-MIPS32 ISAs");
27
+ case Match_MnemonicFail:
28
+ return Error(IDLoc, "invalid instruction");
29
+ case Match_RequiresDifferentSrcAndDst:
30
+ return Error(IDLoc, "source and destination must be different");
31
+ case Match_RequiresDifferentOperands:
32
+ return Error(IDLoc, "registers must be different");
33
+ case Match_RequiresNoZeroRegister:
34
+ return Error(IDLoc, "invalid operand ($zero) for instruction");
35
+ case Match_RequiresSameSrcAndDst:
36
+ return Error(IDLoc, "source and destination must match");
37
+ case Match_NoFCCRegisterForCurrentISA:
38
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "non-zero fcc register doesn't exist in current ISA level");
39
+ case Match_Immz:
40
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected '0'");
41
+ case Match_UImm1_0:
42
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 1-bit unsigned immediate");
43
+ case Match_UImm2_0:
44
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 2-bit unsigned immediate");
45
+ case Match_UImm2_1:
46
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected immediate in range 1 .. 4");
47
+ case Match_UImm3_0:
48
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 3-bit unsigned immediate");
49
+ case Match_UImm4_0:
50
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 4-bit unsigned immediate");
51
+ case Match_SImm4_0:
52
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 4-bit signed immediate");
53
+ case Match_UImm5_0:
54
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 5-bit unsigned immediate");
55
+ case Match_SImm5_0:
56
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 5-bit signed immediate");
57
+ case Match_UImm5_1:
58
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected immediate in range 1 .. 32");
59
+ case Match_UImm5_32:
60
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected immediate in range 32 .. 63");
61
+ case Match_UImm5_33:
62
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected immediate in range 33 .. 64");
63
+ case Match_UImm5_0_Report_UImm6:
64
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 6-bit unsigned immediate");
65
+ case Match_UImm5_Lsl2:
66
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected both 7-bit unsigned immediate and multiple of 4");
67
+ case Match_UImmRange2_64:
68
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected immediate in range 2 .. 64");
69
+ case Match_UImm6_0:
70
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 6-bit unsigned immediate");
71
+ case Match_UImm6_Lsl2:
72
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected both 8-bit unsigned immediate and multiple of 4");
73
+ case Match_SImm6_0:
74
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 6-bit signed immediate");
75
+ case Match_UImm7_0:
76
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 7-bit unsigned immediate");
77
+ case Match_UImm7_N1:
78
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected immediate in range -1 .. 126");
79
+ case Match_SImm7_Lsl2:
80
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected both 9-bit signed immediate and multiple of 4");
81
+ case Match_UImm8_0:
82
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 8-bit unsigned immediate");
83
+ case Match_UImm10_0:
84
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 10-bit unsigned immediate");
85
+ case Match_SImm10_0:
86
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 10-bit signed immediate");
87
+ case Match_SImm11_0:
88
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 11-bit signed immediate");
89
+ case Match_UImm16:
90
+ case Match_UImm16_Relaxed:
91
+ case Match_UImm16_AltRelaxed:
92
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 16-bit unsigned immediate");
93
+ case Match_SImm16:
94
+ case Match_SImm16_Relaxed:
95
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 16-bit signed immediate");
96
+ case Match_SImm19_Lsl2:
97
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected both 19-bit signed immediate and multiple of 4");
98
+ case Match_UImm20_0:
99
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 20-bit unsigned immediate");
100
+ case Match_UImm26_0:
101
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 26-bit unsigned immediate");
102
+ case Match_SImm32:
103
+ case Match_SImm32_Relaxed:
104
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 32-bit signed immediate");
105
+ case Match_UImm32_Coerced:
106
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected 32-bit immediate");
107
+ case Match_MemSImm9:
108
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 9-bit signed offset");
109
+ case Match_MemSImm10:
110
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 10-bit signed offset");
111
+ case Match_MemSImm10Lsl1:
112
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 11-bit signed offset and multiple of 2");
113
+ case Match_MemSImm10Lsl2:
114
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 12-bit signed offset and multiple of 4");
115
+ case Match_MemSImm10Lsl3:
116
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 13-bit signed offset and multiple of 8");
117
+ case Match_MemSImm11:
118
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 11-bit signed offset");
119
+ case Match_MemSImm12:
120
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 12-bit signed offset");
121
+ case Match_MemSImm16:
122
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 16-bit signed offset");
123
+ case Match_MemSImmPtr:
124
+ return Error(RefineErrorLoc(IDLoc, Operands, ErrorInfo), "expected memory with 32-bit signed offset");
125
+ case Match_RequiresPosSizeRange0_32: {
126
+ SMLoc ErrorStart = Operands[3]->getStartLoc();
127
+ SMLoc ErrorEnd = Operands[4]->getEndLoc();
128
+ return Error(ErrorStart, "size plus position are not in the range 0 .. 32", SMRange(ErrorStart, ErrorEnd));
129
+ }
130
+ case Match_RequiresPosSizeUImm6: {
131
+ SMLoc ErrorStart = Operands[3]->getStartLoc();
132
+ SMLoc ErrorEnd = Operands[4]->getEndLoc();
133
+ return Error(ErrorStart, "size plus position are not in the range 1 .. 63", SMRange(ErrorStart, ErrorEnd));
134
+ }
135
+ case Match_RequiresPosSizeRange33_64: {
136
+ SMLoc ErrorStart = Operands[3]->getStartLoc();
137
+ SMLoc ErrorEnd = Operands[4]->getEndLoc();
138
+ return Error(ErrorStart, "size plus position are not in the range 33 .. 64", SMRange(ErrorStart, ErrorEnd));
139
+ }
140
+ }
141
+ llvm_unreachable("Implement any new match types added!");
142
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/Operand.cpp ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ MipsOperand(KindTy K, MipsAsmParser &Parser) : MCParsedAsmOperand(), Kind(K), AsmParser(Parser) {
2
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/Operand2.cpp ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ MipsOperand(KindTy K, MipsAsmParser &Parser) : MCParsedAsmOperand(), Kind(K), AsmParser(Parser) {
2
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/ParseDirective.cpp ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {
2
+ MCAsmParser &Parser = getParser();
3
+ StringRef IDVal = DirectiveID.getString();
4
+ if (IDVal == ".cpadd") {
5
+ parseDirectiveCpAdd(DirectiveID.getLoc());
6
+ return false;
7
+ }
8
+ if (IDVal == ".cpload") {
9
+ parseDirectiveCpLoad(DirectiveID.getLoc());
10
+ return false;
11
+ }
12
+ if (IDVal == ".cprestore") {
13
+ parseDirectiveCpRestore(DirectiveID.getLoc());
14
+ return false;
15
+ }
16
+ if (IDVal == ".cplocal") {
17
+ parseDirectiveCpLocal(DirectiveID.getLoc());
18
+ return false;
19
+ }
20
+ if (IDVal == ".ent") {
21
+ StringRef SymbolName;
22
+ if (Parser.parseIdentifier(SymbolName)) {
23
+ reportParseError("expected identifier after .ent");
24
+ return false;
25
+ }
26
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
27
+ if (getLexer().isNot(AsmToken::Comma)) {
28
+ reportParseError("unexpected token, expected end of statement");
29
+ return false;
30
+ }
31
+ Parser.Lex();
32
+ const MCExpr *DummyNumber;
33
+ int64_t DummyNumberVal;
34
+ if (Parser.parseExpression(DummyNumber)) {
35
+ reportParseError("expected number after comma");
36
+ return false;
37
+ }
38
+ if (!DummyNumber->evaluateAsAbsolute(DummyNumberVal)) {
39
+ reportParseError("expected an absolute expression after comma");
40
+ return false;
41
+ }
42
+ }
43
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
44
+ reportParseError("unexpected token, expected end of statement");
45
+ return false;
46
+ }
47
+ MCSymbol *Sym = getContext().getOrCreateSymbol(SymbolName);
48
+ getTargetStreamer().emitDirectiveEnt(*Sym);
49
+ CurrentFn = Sym;
50
+ IsCpRestoreSet = false;
51
+ return false;
52
+ }
53
+ if (IDVal == ".end") {
54
+ StringRef SymbolName;
55
+ if (Parser.parseIdentifier(SymbolName)) {
56
+ reportParseError("expected identifier after .end");
57
+ return false;
58
+ }
59
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
60
+ reportParseError("unexpected token, expected end of statement");
61
+ return false;
62
+ }
63
+ if (CurrentFn == nullptr) {
64
+ reportParseError(".end used without .ent");
65
+ return false;
66
+ }
67
+ if ((SymbolName != CurrentFn->getName())) {
68
+ reportParseError(".end symbol does not match .ent symbol");
69
+ return false;
70
+ }
71
+ getTargetStreamer().emitDirectiveEnd(SymbolName);
72
+ CurrentFn = nullptr;
73
+ IsCpRestoreSet = false;
74
+ return false;
75
+ }
76
+ if (IDVal == ".frame") {
77
+ SmallVector<std::unique_ptr<MCParsedAsmOperand>, 1> TmpReg;
78
+ OperandMatchResultTy ResTy = parseAnyRegister(TmpReg);
79
+ if (ResTy == MatchOperand_NoMatch || ResTy == MatchOperand_ParseFail) {
80
+ reportParseError("expected stack register");
81
+ return false;
82
+ }
83
+ MipsOperand &StackRegOpnd = static_cast<MipsOperand &>(*TmpReg[0]);
84
+ if (!StackRegOpnd.isGPRAsmReg()) {
85
+ reportParseError(StackRegOpnd.getStartLoc(), "expected general purpose register");
86
+ return false;
87
+ }
88
+ unsigned StackReg = StackRegOpnd.getGPR32Reg();
89
+ if (Parser.getTok().is(AsmToken::Comma))
90
+ Parser.Lex();
91
+ else {
92
+ reportParseError("unexpected token, expected comma");
93
+ return false;
94
+ }
95
+ const MCExpr *FrameSize;
96
+ int64_t FrameSizeVal;
97
+ if (Parser.parseExpression(FrameSize)) {
98
+ reportParseError("expected frame size value");
99
+ return false;
100
+ }
101
+ if (!FrameSize->evaluateAsAbsolute(FrameSizeVal)) {
102
+ reportParseError("frame size not an absolute expression");
103
+ return false;
104
+ }
105
+ if (Parser.getTok().is(AsmToken::Comma))
106
+ Parser.Lex();
107
+ else {
108
+ reportParseError("unexpected token, expected comma");
109
+ return false;
110
+ }
111
+ TmpReg.clear();
112
+ ResTy = parseAnyRegister(TmpReg);
113
+ if (ResTy == MatchOperand_NoMatch || ResTy == MatchOperand_ParseFail) {
114
+ reportParseError("expected return register");
115
+ return false;
116
+ }
117
+ MipsOperand &ReturnRegOpnd = static_cast<MipsOperand &>(*TmpReg[0]);
118
+ if (!ReturnRegOpnd.isGPRAsmReg()) {
119
+ reportParseError(ReturnRegOpnd.getStartLoc(), "expected general purpose register");
120
+ return false;
121
+ }
122
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
123
+ reportParseError("unexpected token, expected end of statement");
124
+ return false;
125
+ }
126
+ getTargetStreamer().emitFrame(StackReg, FrameSizeVal, ReturnRegOpnd.getGPR32Reg());
127
+ IsCpRestoreSet = false;
128
+ return false;
129
+ }
130
+ if (IDVal == ".set") {
131
+ parseDirectiveSet();
132
+ return false;
133
+ }
134
+ if (IDVal == ".mask" || IDVal == ".fmask") {
135
+ const MCExpr *BitMask;
136
+ int64_t BitMaskVal;
137
+ if (Parser.parseExpression(BitMask)) {
138
+ reportParseError("expected bitmask value");
139
+ return false;
140
+ }
141
+ if (!BitMask->evaluateAsAbsolute(BitMaskVal)) {
142
+ reportParseError("bitmask not an absolute expression");
143
+ return false;
144
+ }
145
+ if (Parser.getTok().is(AsmToken::Comma))
146
+ Parser.Lex();
147
+ else {
148
+ reportParseError("unexpected token, expected comma");
149
+ return false;
150
+ }
151
+ const MCExpr *FrameOffset;
152
+ int64_t FrameOffsetVal;
153
+ if (Parser.parseExpression(FrameOffset)) {
154
+ reportParseError("expected frame offset value");
155
+ return false;
156
+ }
157
+ if (!FrameOffset->evaluateAsAbsolute(FrameOffsetVal)) {
158
+ reportParseError("frame offset not an absolute expression");
159
+ return false;
160
+ }
161
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
162
+ reportParseError("unexpected token, expected end of statement");
163
+ return false;
164
+ }
165
+ if (IDVal == ".mask")
166
+ getTargetStreamer().emitMask(BitMaskVal, FrameOffsetVal);
167
+ else
168
+ getTargetStreamer().emitFMask(BitMaskVal, FrameOffsetVal);
169
+ return false;
170
+ }
171
+ if (IDVal == ".nan")
172
+ return parseDirectiveNaN();
173
+
174
+ if (IDVal == ".gpword") {
175
+ parseDirectiveGpWord();
176
+ return false;
177
+ }
178
+ if (IDVal == ".gpdword") {
179
+ parseDirectiveGpDWord();
180
+ return false;
181
+ }
182
+
183
+ if (IDVal == ".dtprelword") {
184
+ parseDirectiveDtpRelWord();
185
+ return false;
186
+ }
187
+ if (IDVal == ".dtpreldword") {
188
+ parseDirectiveDtpRelDWord();
189
+ return false;
190
+ }
191
+ if (IDVal == ".tprelword") {
192
+ parseDirectiveTpRelWord();
193
+ return false;
194
+ }
195
+ if (IDVal == ".tpreldword") {
196
+ parseDirectiveTpRelDWord();
197
+ return false;
198
+ }
199
+ if (IDVal == ".option") {
200
+ parseDirectiveOption();
201
+ return false;
202
+ }
203
+ if (IDVal == ".abicalls") {
204
+ getTargetStreamer().emitDirectiveAbiCalls();
205
+ if (Parser.getTok().isNot(AsmToken::EndOfStatement)) {
206
+ Error(Parser.getTok().getLoc(), "unexpected token, expected end of statement");
207
+ }
208
+ return false;
209
+ }
210
+ if (IDVal == ".cpsetup") {
211
+ parseDirectiveCPSetup();
212
+ return false;
213
+ }
214
+ if (IDVal == ".cpreturn") {
215
+ parseDirectiveCPReturn();
216
+ return false;
217
+ }
218
+ if (IDVal == ".module") {
219
+ parseDirectiveModule();
220
+ return false;
221
+ }
222
+ if (IDVal == ".llvm_internal_mips_reallow_module_directive") {
223
+ parseInternalDirectiveReallowModule();
224
+ return false;
225
+ }
226
+ if (IDVal == ".insn") {
227
+ parseInsnDirective();
228
+ return false;
229
+ }
230
+ if (IDVal == ".rdata") {
231
+ parseRSectionDirective(".rodata");
232
+ return false;
233
+ }
234
+ if (IDVal == ".sbss") {
235
+ parseSSectionDirective(IDVal, ELF::SHT_NOBITS);
236
+ return false;
237
+ }
238
+ if (IDVal == ".sdata") {
239
+ parseSSectionDirective(IDVal, ELF::SHT_PROGBITS);
240
+ return false;
241
+ }
242
+ return true;
243
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/ParseInstruction.cpp ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ bool MipsAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands) {
2
+ MCAsmParser &Parser = getParser();
3
+ LLVM_DEBUG(dbgs() << "ParseInstruction\n");
4
+ getTargetStreamer().forbidModuleDirective();
5
+ if (!mnemonicIsValid(Name, 0)) {
6
+ FeatureBitset FBS = ComputeAvailableFeatures(getSTI().getFeatureBits());
7
+ std::string Suggestion = MipsMnemonicSpellCheck(Name, FBS);
8
+ return Error(NameLoc, "unknown instruction" + Suggestion);
9
+ }
10
+ Operands.push_back(MipsOperand::CreateToken(Name, NameLoc, *this));
11
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
12
+ if (parseOperand(Operands, Name)) {
13
+ SMLoc Loc = getLexer().getLoc();
14
+ return Error(Loc, "unexpected token in argument list");
15
+ }
16
+ if (getLexer().is(AsmToken::LBrac) && parseBracketSuffix(Name, Operands))
17
+ return true;
18
+ while (getLexer().is(AsmToken::Comma)) {
19
+ Parser.Lex();
20
+ if (parseOperand(Operands, Name)) {
21
+ SMLoc Loc = getLexer().getLoc();
22
+ return Error(Loc, "unexpected token in argument list");
23
+ }
24
+ if (getLexer().is(AsmToken::LBrac)) {
25
+ if (parseBracketSuffix(Name, Operands))
26
+ return true;
27
+ }
28
+ else if (getLexer().is(AsmToken::LParen) && parseParenSuffix(Name, Operands))
29
+ return true;
30
+ }
31
+ }
32
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
33
+ SMLoc Loc = getLexer().getLoc();
34
+ return Error(Loc, "unexpected token in argument list");
35
+ }
36
+ Parser.Lex();
37
+ return false;
38
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/ParseRegister.cpp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ bool MipsAsmParser::ParseRegister(unsigned &RegNo, SMLoc &StartLoc, SMLoc &EndLoc) {
2
+ return tryParseRegister(RegNo, StartLoc, EndLoc) != MatchOperand_Success;
3
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addCSRSystemRegisterOperands.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addExpr.cpp ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ void addExpr(MCInst &Inst, const MCExpr *Expr) const {
2
+ if (!Expr)
3
+ Inst.addOperand(MCOperand::createImm(0));
4
+ else if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(Expr))
5
+ Inst.addOperand(MCOperand::createImm(CE->getValue()));
6
+ else
7
+ Inst.addOperand(MCOperand::createExpr(Expr));
8
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addFRMArgOperands.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addFenceArgOperands.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addImmOperands.cpp ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ void addImmOperands(MCInst &Inst, unsigned N) const {
2
+ assert(N == 1 && "Invalid number of operands!");
3
+ addExpr(Inst, getImm());
4
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addRegOperands.cpp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ void addRegOperands(MCInst &Inst, unsigned N) const {
2
+ llvm_unreachable("Use a custom parser instead");
3
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/addVTypeIOperands.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/classifySymbolRef.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/convertFPR64ToFPR16.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/convertFPR64ToFPR32.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createImm.cpp ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ static std::unique_ptr<MipsOperand> createImm(const MCExpr *Val, SMLoc S, SMLoc E, MipsAsmParser &Parser) {
2
+ auto Op = std::make_unique<MipsOperand>(k_Immediate, Parser);
3
+ Op->Imm.Val = Val;
4
+ Op->StartLoc = S;
5
+ Op->EndLoc = E;
6
+ return Op;
7
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createReg.cpp ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ static std::unique_ptr<MipsOperand> CreateReg(unsigned Index, StringRef Str, RegKind RegKind, const MCRegisterInfo *RegInfo, SMLoc S, SMLoc E, MipsAsmParser &Parser) {
2
+ auto Op = std::make_unique<MipsOperand>(k_RegisterIndex, Parser);
3
+ Op->RegIdx.Index = Index;
4
+ Op->RegIdx.RegInfo = RegInfo;
5
+ Op->RegIdx.Kind = RegKind;
6
+ Op->RegIdx.Tok.Data = Str.data();
7
+ Op->RegIdx.Tok.Length = Str.size();
8
+ Op->StartLoc = S;
9
+ Op->EndLoc = E;
10
+ return Op;
11
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createSysReg.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createToken.cpp ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ static std::unique_ptr<MipsOperand> CreateToken(StringRef Str, SMLoc S, MipsAsmParser &Parser) {
2
+ auto Op = std::make_unique<MipsOperand>(k_Token, Parser);
3
+ Op->Tok.Data = Str.data();
4
+ Op->Tok.Length = Str.size();
5
+ Op->StartLoc = S;
6
+ Op->EndLoc = S;
7
+ return Op;
8
+ }
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/createVType.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/defaultMaskRegOp.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/emitToStreamer.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/evaluateConstantImm.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None
Scripts/Exp/ForkFlow/Mips_Code/PULP/Assembler/AsmParser/generateImmOutOfRangeError.cpp ADDED
@@ -0,0 +1 @@
 
 
1
+ None