struct / union in initializer, RFE #901.
[sdcc.git] / sdcc-extra / historygraphs / coremark-1.0-z80.patch
blob942ff3fb289384d338ee182100383b39f6d85d56
1 Gemeinsame Unterverzeichnisse: coremark_v1.0/barebones und coremark-z80/barebones.
2 Nur in coremark_v1.0: coremark-1.0-z80.patch.
3 diff -u coremark_v1.0/core_portme.c coremark-z80/core_portme.c
4 --- coremark_v1.0/core_portme.c 2021-07-05 11:44:20.727282106 +0200
5 +++ coremark-z80/core_portme.c 2021-07-05 11:43:58.622525621 +0200
6 @@ -5,9 +5,13 @@
7 Author : Shay Gal-On, EEMBC
8 Legal : TODO!
9 */
11 +#include <stdio.h>
12 #include "coremark.h"
13 #include "core_portme.h"
15 +#define ITERATIONS 100
17 #if VALIDATION_RUN
18 volatile ee_s32 seed1_volatile=0x3415;
19 volatile ee_s32 seed2_volatile=0x3415;
20 @@ -30,20 +34,21 @@
21 e.g. Read value from on board RTC, read value from cpu clock cycles performance counter etc.
22 Sample implementation for standard time.h and windows.h definitions included.
24 -CORETIMETYPE barebones_clock() {
25 - #error "You must implement a method to measure time in barebones_clock()! This function should return current time.\n"
27 /* Define : TIMER_RES_DIVIDER
28 Divider to trade off timer resolution and total time that can be measured.
30 Use lower values to increase resolution, but make sure that overflow does not occur.
31 If there are issues with the return value overflowing, increase this value.
33 -#define GETMYTIME(_t) (*_t=barebones_clock())
34 +#define CLOCKS_PER_SEC 32768
35 +#define NSECS_PER_SEC CLOCKS_PER_SEC
36 +unsigned long clock(void);
37 +//#define CORETIMETYPE clock_t
38 +#define GETMYTIME(_t) (*_t=clock())
39 #define MYTIMEDIFF(fin,ini) ((fin)-(ini))
40 #define TIMER_RES_DIVIDER 1
41 #define SAMPLE_TIME_IMPLEMENTATION 1
42 -#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
43 +#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
45 /** Define Host specific (POSIX), or target specific global time variables. */
46 static CORETIMETYPE start_time_val, stop_time_val;
47 @@ -92,13 +97,16 @@
49 ee_u32 default_num_contexts=1;
51 +void init(void);
53 /* Function : portable_init
54 Target specific initialization code
55 Test for some common mistakes.
57 void portable_init(core_portable *p, int *argc, char *argv[])
59 - #error "Call board initialization routines in portable init (if needed), in particular initialize UART!\n"
60 + init();
62 if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
63 ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
65 @@ -115,4 +123,67 @@
66 p->portable_id=0;
69 +#include <stdio.h>
70 +#include <stdint.h>
72 +__sfr __at 0x00 Exec_port;
73 +__sfr __at 0x01 StorOpc_port;
75 +volatile CORE_TICKS ticks;
77 +void init (void)
79 + // Setup tick interrupt.
80 + StorOpc_port = 0x0f; // Set tick opcode
81 + Exec_port = 10; // Once every 10 ms.
83 + StorOpc_port = 0x0e; // Set interrupt opcode
84 + Exec_port = 0x02; // Tick interrupt only.
86 +__asm
87 + im 1
88 + ei
89 +__endasm;
92 +void tick (void)
94 + ticks++;
97 +CORE_TICKS clock(void)
99 + long ret;
100 + do
101 + ret = ticks;
102 + while (ret != ticks);
103 + return(ret);
106 +#if defined(__SDCC) && __SDCC_REVISION < 9624 // Old SDCC weirdness
107 +void putchar (char c)
109 +__asm
110 + di
111 +__endasm;
112 + StorOpc_port = 0x1;
113 + Exec_port = c;
114 +__asm
115 + ei
116 +__endasm;
118 +#else // Standard C
119 +int putchar (int c)
121 +__asm
122 + di
123 +__endasm;
124 + StorOpc_port = 0x1;
125 + Exec_port = c;
126 +__asm
127 + ei
128 +__endasm;
129 + return(c);
131 +#endif
133 diff -u coremark_v1.0/core_portme.h coremark-z80/core_portme.h
134 --- coremark_v1.0/core_portme.h 2021-07-05 11:44:20.727282106 +0200
135 +++ coremark-z80/core_portme.h 2021-07-05 11:08:00.831561745 +0200
136 @@ -16,21 +16,21 @@
137 Define to 1 if the platform supports floating point.
139 #ifndef HAS_FLOAT
140 -#define HAS_FLOAT 1
141 +#define HAS_FLOAT 0
142 #endif
143 /* Configuration : HAS_TIME_H
144 Define to 1 if platform has the time.h header file,
145 and implementation of functions thereof.
147 #ifndef HAS_TIME_H
148 -#define HAS_TIME_H 1
149 +#define HAS_TIME_H 0
150 #endif
151 /* Configuration : USE_CLOCK
152 Define to 1 if platform has the time.h header file,
153 and implementation of functions thereof.
155 #ifndef USE_CLOCK
156 -#define USE_CLOCK 1
157 +#define USE_CLOCK 0
158 #endif
159 /* Configuration : HAS_STDIO
160 Define to 1 if the platform has stdio.h.
161 @@ -42,10 +42,19 @@
162 Define to 1 if the platform has stdio.h and implements the printf function.
164 #ifndef HAS_PRINTF
165 -#define HAS_PRINTF 0
166 +#define HAS_PRINTF 1
167 #endif
170 +/* Configuration : CORE_TICKS
171 + Define type of return from the timing functions.
172 + */
173 +//#include <time.h>
174 +//typedef clock_t CORE_TICKS;
175 +typedef unsigned long CORE_TICKS;
176 +CORE_TICKS clock(void);
177 +/* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
178 + Initialize these strings per platform
180 /* Definitions : COMPILER_VERSION, COMPILER_FLAGS, MEM_LOCATION
181 Initialize these strings per platform
183 @@ -57,7 +66,7 @@
184 #endif
185 #endif
186 #ifndef COMPILER_FLAGS
187 - #define COMPILER_FLAGS FLAGS_STR /* "Please put compiler flags here (e.g. -o3)" */
188 + #define COMPILER_FLAGS "Please put compiler flags here (e.g. -o3)"
189 #endif
190 #ifndef MEM_LOCATION
191 #define MEM_LOCATION "STACK"
192 @@ -69,15 +78,18 @@
193 *Imprtant* :
194 ee_ptr_int needs to be the data type used to hold pointers, otherwise coremark may fail!!!
196 -typedef signed short ee_s16;
197 -typedef unsigned short ee_u16;
198 -typedef signed int ee_s32;
199 -typedef double ee_f32;
200 -typedef unsigned char ee_u8;
201 -typedef unsigned int ee_u32;
202 -typedef ee_u32 ee_ptr_int;
203 +#include <stdio.h>
204 +#include <stddef.h>
205 +#include <stdint.h>
207 +typedef int16_t ee_s16;
208 +typedef uint16_t ee_u16;
209 +typedef int32_t ee_s32;
210 +typedef float ee_f32;
211 +typedef uint8_t ee_u8;
212 +typedef uint32_t ee_u32;
213 +typedef uintptr_t ee_ptr_int;
214 typedef size_t ee_size_t;
215 -#define NULL ((void *)0)
216 /* align_mem :
217 This macro is used to align an offset to point to a 32b value. It is used in the Matrix algorithm to initialize the input memory blocks.
219 @@ -87,7 +99,7 @@
220 Define type of return from the timing functions.
222 #define CORETIMETYPE ee_u32
223 -typedef ee_u32 CORE_TICKS;
224 +//typedef ee_u32 CORE_TICKS;
226 /* Configuration : SEED_METHOD
227 Defines method to get seed values that cannot be computed at compile time.
228 @@ -146,7 +158,7 @@
229 This flag only matters if MULTITHREAD has been defined to a value greater then 1.
231 #ifndef MAIN_HAS_NOARGC
232 -#define MAIN_HAS_NOARGC 0
233 +#define MAIN_HAS_NOARGC 1
234 #endif
236 /* Configuration : MAIN_HAS_NORETURN
237 @@ -157,7 +169,7 @@
238 1 - platform does not support returning a value from main
240 #ifndef MAIN_HAS_NORETURN
241 -#define MAIN_HAS_NORETURN 0
242 +#define MAIN_HAS_NORETURN 1
243 #endif
245 /* Variable : default_num_contexts
246 Nur in coremark_v1.0: core_portme.mak.
247 Nur in coremark-z80: crt0.s.
248 Gemeinsame Unterverzeichnisse: coremark_v1.0/cygwin und coremark-z80/cygwin.
249 Gemeinsame Unterverzeichnisse: coremark_v1.0/docs und coremark-z80/docs.
250 Gemeinsame Unterverzeichnisse: coremark_v1.0/linux und coremark-z80/linux.
251 Gemeinsame Unterverzeichnisse: coremark_v1.0/linux64 und coremark-z80/linux64.
252 diff -u coremark_v1.0/Makefile coremark-z80/Makefile
253 --- coremark_v1.0/Makefile 2009-07-10 19:48:43.000000000 +0200
254 +++ coremark-z80/Makefile 2021-07-05 11:08:00.831561745 +0200
255 @@ -1,141 +1,19 @@
256 -#Author : Shay Gal-On, EEMBC
258 -#This file is part of EEMBC(R) and CoreMark(TM), which are Copyright (C) 2009
259 -#All rights reserved.
261 -#EEMBC CoreMark Software is a product of EEMBC and is provided under the terms of the
262 -#CoreMark License that is distributed with the official EEMBC COREMARK Software release.
263 -#If you received this EEMBC CoreMark Software without the accompanying CoreMark License,
264 -#you must discontinue use and download the official release from www.coremark.org.
266 -#Also, if you are publicly displaying scores generated from the EEMBC CoreMark software,
267 -#make sure that you are in compliance with Run and Reporting rules specified in the accompanying readme.txt file.
269 -#EEMBC
270 -#4354 Town Center Blvd. Suite 114-200
271 -#El Dorado Hills, CA, 95762
274 -# Make sure the default target is to simply build and run the benchmark.
275 -RSTAMP = v1.0
277 -.PHONY: run score
278 -run: $(OUTFILE) rerun score
280 -score:
281 - @echo "Check run1.log and run2.log for results."
282 - @echo "See readme.txt for run and reporting rules."
284 -ifndef PORT_DIR
285 -# Ports for a couple of common self hosted platforms
286 -UNAME=$(shell if [[ `uname 2> /dev/null` ]] ; then uname ; fi)
287 -ifneq (,$(findstring CYGWIN,$(UNAME)))
288 -PORT_DIR=cygwin
289 -endif
290 -ifneq (,$(findstring Linux,$(UNAME)))
291 -MACHINE=$(shell uname -m)
292 -ifneq (,$(findstring 64,$(MACHINE)))
293 -PORT_DIR=linux64
294 -else
295 -PORT_DIR=linux
296 -endif
297 -endif
298 -endif
299 -ifndef PORT_DIR
300 -$(error PLEASE define PORT_DIR! (e.g. make PORT_DIR=simple))
301 -endif
302 -vpath %.c $(PORT_DIR)
303 -vpath %.h $(PORT_DIR)
304 -vpath %.mak $(PORT_DIR)
305 -include $(PORT_DIR)/core_portme.mak
307 -ifndef $(ITERATIONS)
308 -ITERATIONS=0
309 -endif
310 -ifdef REBUILD
311 -FORCE_REBUILD=force_rebuild
312 -endif
314 -CFLAGS += -DITERATIONS=$(ITERATIONS)
316 -CORE_FILES = core_list_join core_main core_matrix core_state core_util
317 -ORIG_SRCS = $(addsuffix .c,$(CORE_FILES))
318 -SRCS = $(ORIG_SRCS) $(PORT_SRCS)
319 -OBJS = $(addprefix $(OPATH),$(addsuffix $(OEXT),$(CORE_FILES)) $(PORT_OBJS))
320 -OUTNAME = coremark$(EXE)
321 -OUTFILE = $(OPATH)$(OUTNAME)
322 -LOUTCMD = $(OFLAG) $(OUTFILE) $(LFLAGS_END)
323 -OUTCMD = $(OUTFLAG) $(OUTFILE) $(LFLAGS_END)
325 -HEADERS = coremark.h
326 -CHECK_FILES = $(ORIG_SRCS) $(HEADERS)
328 -$(OPATH):
329 - $(MKDIR) $(OPATH)
331 -.PHONY: compile link
332 -ifdef SEPARATE_COMPILE
333 -$(OPATH)$(PORT_DIR):
334 - $(MKDIR) $(OPATH)$(PORT_DIR)
336 -compile: $(OPATH) $(OPATH)$(PORT_DIR) $(OBJS) $(HEADERS)
337 -link: compile
338 - $(LD) $(LFLAGS) $(XLFLAGS) $(OBJS) $(LOUTCMD)
340 -else
342 -compile: $(OPATH) $(SRCS) $(HEADERS)
343 - $(CC) $(CFLAGS) $(XCFLAGS) $(SRCS) $(OUTCMD)
344 -link: compile
345 - @echo "Link performed along with compile"
347 -endif
349 -$(OUTFILE): $(SRCS) $(HEADERS) Makefile core_portme.mak $(FORCE_REBUILD)
350 - $(MAKE) port_prebuild
351 - $(MAKE) link
352 - $(MAKE) port_postbuild
354 -.PHONY: rerun
355 -rerun:
356 - $(MAKE) XCFLAGS="$(XCFLAGS) -DPERFORMANCE_RUN=1" load run1.log
357 - $(MAKE) XCFLAGS="$(XCFLAGS) -DVALIDATION_RUN=1" load run2.log
359 -PARAM1=$(PORT_PARAMS) 0x0 0x0 0x66 $(ITERATIONS)
360 -PARAM2=$(PORT_PARAMS) 0x3415 0x3415 0x66 $(ITERATIONS)
361 -PARAM3=$(PORT_PARAMS) 8 8 8 $(ITERATIONS)
363 -run1.log-PARAM=$(PARAM1) 7 1 2000
364 -run2.log-PARAM=$(PARAM2) 7 1 2000
365 -run3.log-PARAM=$(PARAM3) 7 1 1200
367 -run1.log run2.log run3.log: load
368 - $(MAKE) port_prerun
369 - $(RUN) $(OUTFILE) $($(@)-PARAM) > $(OPATH)$@
370 - $(MAKE) port_postrun
372 -.PHONY: gen_pgo_data
373 -gen_pgo_data: run3.log
375 -.PHONY: load
376 -load: $(OUTFILE)
377 - $(MAKE) port_preload
378 - $(LOAD) $(OUTFILE)
379 - $(MAKE) port_postload
380 +SOURCES = core_list_join.c core_main.c core_matrix.c core_state.c core_util.c core_portme.c
381 +OBJ = crt0.rel $(SOURCES:.c=.rel)
382 +SDCC = sdcc
383 +SDAS = sdas
385 +all: coremark
387 -.PHONY: clean
388 clean:
389 - rm -f $(OUTFILE) $(OPATH)*.log *.info $(OPATH)index.html $(PORT_CLEAN)
390 + rm -f *.ihx *.lnk *.lst *.noi *.rel *.sym *.size *.dot *.lk *.rst *.asm
392 +%.rel: %.c
393 + $(SDCC) -c --std-c99 --fverbose-asm $(SDCCFLAGS) --fverbose-asm $< ||:
395 +crt0.rel: crt0.s
396 + $(SDAS) -plosgff $<
398 +coremark: $(OBJ)
399 + $(SDCC) $(SDCCFLAGS) --no-std-crt0 $(OBJ) -o image.ihx
401 -.PHONY: force_rebuild
402 -force_rebuild:
403 - echo "Forcing Rebuild"
405 -.PHONY: check
406 -check:
407 - md5sum -c coremark.md5
409 -ifdef ETC
410 -# Targets related to testing and releasing CoreMark. Not part of the general release!
411 -include Makefile.internal
412 -endif
413 Gemeinsame Unterverzeichnisse: coremark_v1.0/simple und coremark-z80/simple.