-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
339 lines (301 loc) · 8.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#######################################
# Makefile for the L3 mips simulator ##
#######################################
####################################
# generating the L3 source list #
# /!\ inclusion order matters /!\ #
####################################
L3SRCDIR=src/l3
#########################
# Basic Types and State #
#########################
ifdef CAP
L3SRCBASE+=cheri/tlb-types.spec
else
L3SRCBASE+=tlb/types.spec
endif
L3SRCBASE+=mips-types.spec
L3SRCBASE+=mips-log.spec
L3SRCBASE+=mips-base.spec
################
# PIC and UART #
################
ifndef SIMPLEMEM
L3SRCBASE+=mips-pic.spec
L3SRCBASE+=mips-uart.spec
endif
###############################
# Capabilities and Exceptions #
###############################
ifdef CAP
L3SRCBASE+=cheri/cap-params.spec
L3SRCBASE+=cheri/cap-common.spec
ifeq ($(CAP), c128posits1)
L3SRCBASE+=cheri/cap128-compressed-posits-1.spec
else ifeq ($(CAP), c128c1)
L3SRCBASE+=cheri/cap128-compressed-candidate-1.spec
else ifeq ($(CAP), c128c3)
L3SRCBASE+=cheri/cap128-compressed-candidate-3.spec
ifdef FAST_REP_CHECK
L3SRCBASE+=cheri/cap128-compressed-candidate-3-fast-representable-check.spec
else
L3SRCBASE+=cheri/cap128-compressed-candidate-3-representable-check.spec
endif
else ifeq ($(CAP), c128concentrate)
L3SRCBASE+=cheri/cap128-cheri-concentrate.spec
else ifeq ($(CAP), p64)
L3SRCBASE+=cheri/cap-precise-base-256.spec cheri/cap64-precise.spec
else ifeq ($(CAP), p128)
L3SRCBASE+=cheri/cap-precise-base-256.spec cheri/cap128-precise.spec
else
L3SRCBASE+=cheri/cap-precise-base-256.spec cheri/cap256-precise.spec
endif
L3SRCBASE+=cheri/state.spec
L3SRCBASE+=cheri/exception.spec
else
L3SRCBASE+=mips-exception.spec
endif
#######
# TLB #
#######
L3SRCBASE+=tlb/base.spec
ifdef NOTRANSLATE
ifdef CAP
L3SRCBASE+=cheri/tlb-notranslate.spec
else
L3SRCBASE+=tlb/notranslate.spec
endif
else
ifdef CAP
L3SRCBASE+=cheri/tlb-translate.spec
else
L3SRCBASE+=tlb/translate.spec
endif
endif
ifdef CAP
L3SRCBASE+=cheri/tlb-instructions.spec
else
L3SRCBASE+=tlb/instructions.spec
endif
#########
# Misc. #
#########
L3SRCBASE+=mips-encode-utils.spec
L3SRCBASE+=mips-cache-sizes.spec
#################
# Memory Access #
#################
ifdef CAP
ifdef SIMPLEMEM
L3SRCBASE+=cheri/memaccess-simple.spec
else
ifdef CACHE
L3SRCBASE+=cheri/cache-sizes.spec
L3SRCBASE+=cheri/memory-caches.spec
else
L3SRCBASE+=cheri/memory.spec
endif
L3SRCBASE+=cheri/memory-sml-helpers.spec
L3SRCBASE+=cheri/memaccess.spec
endif
else
ifdef SIMPLEMEM
L3SRCBASE+=mips-memaccess-simple.spec
else
ifdef CACHE
L3SRCBASE+=mips-memory-caches.spec
else
L3SRCBASE+=mips-memory.spec
endif
L3SRCBASE+=mips-memaccess.spec
endif
endif
L3SRCBASE+=mips-CP0.spec
L3SRCBASE+=mips-utils.spec
ifdef CAP
L3SRCBASE+=cheri/cop-access.spec
else
L3SRCBASE+=mips-cop-access.spec
endif
##################################
# Coprocessor 1 (Floating Point) #
##################################
ifdef FPU
L3SRCBASE+=fpu/fpu-log.spec
L3SRCBASE+=fpu/state.spec
L3SRCBASE+=fpu/instructions.spec
else
L3SRCBASE+=cp1-null/instructions.spec
endif
################################
# Coprocessor 2 (Capabilities) #
################################
ifdef CAP
L3SRCBASE+=cheri/instructions.spec
else
L3SRCBASE+=cp2-null/instructions.spec
endif
#####################
# MIPS Instructions #
#####################
ifdef CAP
L3SRCBASE+=cheri/CP0-instructions.spec
else
L3SRCBASE+=mips-CP0-instructions.spec
endif
L3SRCBASE+=mips-instructions.spec
######################
# Instruction Decode #
######################
ifdef FPU
L3SRCBASE+=fpu/decode.spec
else
L3SRCBASE+=cp1-null/decode.spec
endif
ifdef CAP
L3SRCBASE+=cheri/decode.spec
else
L3SRCBASE+=cp2-null/decode.spec
endif
L3SRCBASE+=mips-decode.spec
######################
# Instruction Encode #
######################
ifdef FPU
L3SRCBASE+=fpu/encode.spec
else
L3SRCBASE+=cp1-null/encode.spec
endif
ifdef CAP
L3SRCBASE+=cheri/encode.spec
else
L3SRCBASE+=cp2-null/encode.spec
endif
L3SRCBASE+=mips-encode.spec
###########################################
# Initialisation and Next State Functions #
###########################################
ifdef FPU
L3SRCBASE+=fpu/init.spec
else
L3SRCBASE+=cp1-null/init.spec
endif
ifdef CAP
L3SRCBASE+=cheri/next.spec
L3SRCBASE+=cheri/init.spec
else
L3SRCBASE+=mips-next.spec
L3SRCBASE+=cp2-null/init.spec
endif
ifndef SIMPLEMEM
L3SRCBASE+=mips-init.spec
endif
L3SRC=$(patsubst %, $(L3SRCDIR)/%, $(L3SRCBASE))
# =========================================================================== #
#####################
# HOL / SML sources #
#####################
HOLSRCDIR=src/hol
SMLSRCDIR=src/sml
L3_SML_LIB ?= `l3 --lib-path`
L3SMLLIB=$(shell l3 --lib-path)
# generating the sml source list
SMLLIBSRC+=$(L3SMLLIB)/Runtime.sig
SMLLIBSRC+=$(L3SMLLIB)/Runtime.sml
SMLLIBSRC+=$(L3SMLLIB)/IntExtra.sig
SMLLIBSRC+=$(L3SMLLIB)/IntExtra.sml
SMLLIBSRC+=$(L3SMLLIB)/Nat.sig
SMLLIBSRC+=$(L3SMLLIB)/Nat.sml
SMLLIBSRC+=$(L3SMLLIB)/Set.sig
SMLLIBSRC+=$(L3SMLLIB)/Set.sml
SMLLIBSRC+=$(L3SMLLIB)/L3.sig
SMLLIBSRC+=$(L3SMLLIB)/L3.sml
SMLLIBSRC+=$(L3SMLLIB)/Bitstring.sig
SMLLIBSRC+=$(L3SMLLIB)/Bitstring.sml
SMLLIBSRC+=$(L3SMLLIB)/BitsN.sig
SMLLIBSRC+=$(L3SMLLIB)/BitsN.sml
SMLLIBSRC+=$(L3SMLLIB)/Ptree.sig
SMLLIBSRC+=$(L3SMLLIB)/Ptree.sml
SMLLIBSRC+=$(L3SMLLIB)/Map.sml
SMLLIBSRC+=$(L3SMLLIB)/MutableMapFunctor.sml
SMLLIBSRC+=$(L3SMLLIB)/MutableMap16.sml
SMLLIBSRC+=$(L3SMLLIB)/MutableMap24.sml
SMLLIBSRC+=$(L3SMLLIB)/SSE.sig
SMLLIBSRC+=$(L3SMLLIB)/PolySSE.sml
SMLLIBSRC+=$(L3SMLLIB)/MLtonSSE.sml
SMLLIBSRC+=$(L3SMLLIB)/FP.sig
SMLLIBSRC+=$(L3SMLLIB)/FP32.sml
SMLLIBSRC+=$(L3SMLLIB)/FP64.sml
SMLLIBSRC+=$(L3SMLLIB)/FPConvert.sig
SMLLIBSRC+=$(L3SMLLIB)/FPConvert.sml
SMLSRCBASE+=mips.sig
SMLSRCBASE+=mips.sml
SMLSRCBASE+=run.sml
SMLSRCBASE+=l3mips.mlb
MLBFILE=l3mips.mlb
SSE_FILES=$(L3SMLLIB)/sse_float.c $(L3SMLLIB)/mlton_sse_float.c
SMLSRC=$(patsubst %, $(SMLSRCDIR)/%, $(SMLSRCBASE))
# memory subsystem params
L1ISIZE ?= 32768
L1IWAYS ?= 2
L1DSIZE ?= 32768
L1DWAYS ?= 4
L1LINESIZE ?= 128
L2SIZE ?= 262144
L2WAYS ?= 4
L2LINESIZE ?= 128
NAME_STR=l3mips
ifdef NOTRANSLATE
NAME_STR:=$(NAME_STR)-no_translate
endif
ifdef SIMPLEMEM
NAME_STR:=$(NAME_STR)-simple_mem
endif
ifdef FPU
NAME_STR:=$(NAME_STR)-fpu
endif
ifdef CAP
NAME_STR:=$(NAME_STR)-cheri_$(CAP)
endif
ifdef CACHE
NAME_STR:=$(NAME_STR)-l2_$(L2SIZE)B_$(L2WAYS)ways_$(L2LINESIZE)Bpl
endif
SIM ?= $(NAME_STR)
SIMPOLY ?= $(shell pwd)/$(NAME_STR)-poly
SIM_PROFILE ?= l3mips_prof
SIM_COVERAGE ?= l3mips_coverage
M4_CHERI_FILES = $(basename $(wildcard ${L3SRCDIR}/cheri/*.spec.m4))
M4_FILES = $(basename $(wildcard ${L3SRCDIR}/*.spec.m4))
# =========================================================================== #
################
# make targets #
################
all: $(SIM)
hol: ${L3SRC}
echo 'HolExport.spec ("${L3SRC}", "${HOLSRCDIR}/cheri nobigrecords nosigdocs")' | l3
isabelle: ${L3SRC}
echo 'IsabelleExport.spec ("${L3SRC}", "${HOLSRCDIR}/CHERI")' | l3
isabelle_monadic: ${L3SRC}
echo 'IsabelleExport.spec ("${L3SRC}", "${HOLSRCDIR}/CHERI_Monadic monadic")' | l3
count: ${L3SRC}
@wc -l ${L3SRC}
${L3SRCDIR}/%.spec: ${L3SRCDIR}/%.spec.m4
m4 -I ${L3SRCDIR}/cheri/ -D CAP=$(CAP) -D L2SIZE=$(L2SIZE) -D L2WAYS=$(L2WAYS) -D L2LINESIZE=$(L2LINESIZE) -D L1ISIZE=$(L1ISIZE) -D L1IWAYS=$(L1IWAYS) -D L1DSIZE=$(L1DSIZE) -D L1DWAYS=$(L1DWAYS) -D L1LINESIZE=$(L1LINESIZE) $^ > $@
${L3SRCDIR}/cheri/%.spec: ${L3SRCDIR}/cheri/%.spec.m4
m4 -I ${L3SRCDIR}/cheri/ -D CAP=$(CAP) -D L2SIZE=$(L2SIZE) -D L2WAYS=$(L2WAYS) -D L2LINESIZE=$(L2LINESIZE) -D L1ISIZE=$(L1ISIZE) -D L1IWAYS=$(L1IWAYS) -D L1DSIZE=$(L1DSIZE) -D L1DWAYS=$(L1DWAYS) -D L1LINESIZE=$(L1LINESIZE) $^ > $@
MLTON ?= mlton
POLYC ?= polyc
${SMLSRCDIR}/mips.sig ${SMLSRCDIR}/mips.sml: ${L3SRC}
echo 'SMLExport.spec ("${L3SRC}", "${SMLSRCDIR}/mips intinf")' | l3
poly: ${SMLSRC} ${SMLLIBSRC} ${SMLSRCDIR}/run-poly.sml
cd ${SMLSRCDIR} && $(POLYC) -o ${SIMPOLY} run-poly.sml
${SIM}: ${SMLSRC} ${SMLLIBSRC}
$(MLTON) -default-ann 'allowFFI true' -inline 1000 -default-type intinf -verbose 2 -output ${SIM} -mlb-path-var 'L3_SML_LIB '$(L3_SML_LIB) ${SMLSRCDIR}/$(MLBFILE) $(SSE_FILES)
${SIM_PROFILE}: ${SMLSRC} ${SMLLIBSRC}
$(MLTON) -default-ann 'allowFFI true' -profile time -profile-include '.*' -inline 1000 -default-type intinf -verbose 2 -output ./${SIM_PROFILE} -mlb-path-var 'L3_SML_LIB '$(L3_SML_LIB) ${SMLSRCDIR}/$(MLBFILE) $(SSE_FILES)
${SIM_COVERAGE}: ${SMLSRC} ${SMLLIBSRC}
$(MLTON) -default-ann 'allowFFI true' -profile count -profile-branch true -inline 1000 -default-type intinf -verbose 2 -output ./${SIM_COVERAGE} -mlb-path-var 'L3_SML_LIB '$(L3_SML_LIB) ${SMLSRCDIR}/$(MLBFILE) $(SSE_FILES)
clean:
rm -f ${SMLSRCDIR}/mips.sig ${SMLSRCDIR}/mips.sml
rm -f $(M4_CHERI_FILES)
rm -f $(M4_FILES)