- Upgrade to romcc version 0.63

This includes more test cases
  Lots of small bug fixes
  A built in C preprocessor
  Initial support for not inlining everything
  __attribute__((noinline)) works
  Better command line options and help
  Constants arrays can be read at compile time
  Asm statements that are not volatile will now be removed when their outputs go unused
  Loads and stores that are not volatile will be removed when their values go unused
  The number of FIXMES in the code is finally starting to go down.


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1582 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Eric Biederman 2004-05-28 14:11:54 +00:00
parent 7664d1cb87
commit 9008960339
42 changed files with 13557 additions and 2312 deletions

View File

@ -1,11 +1,8 @@
VERSION:=0.38
RELEASE_DATE:=18 December 2003
PACKAGE:=romcc
# Move the configuration defines to makefile.conf
CC=gcc
CPPFLAGS=-DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(RELEASE_DATE)"'
CPPFLAGS=
CFLAGS= -g -Wall $(CPPFLAGS)
CPROF_FLAGS=-pg -fprofile-arcs
@ -26,11 +23,16 @@ LINUX_TESTS=\
linux_test6.c \
linux_test7.c \
linux_test8.c \
linux_test9.c \
linux_test10.c \
linux_test11.c \
linux_test12.c \
linux_test13.c \
TESTS=\
hello_world.c \
hello_world1.c \
hello_world2.c \
simple_test.c \
simple_test1.c \
simple_test2.c \
simple_test3.c \
simple_test4.c \
@ -91,10 +93,24 @@ TESTS=\
simple_test67.c \
simple_test68.c \
simple_test69.c \
simple_test70.c \
simple_test71.c \
simple_test72.c \
simple_test73.c \
raminit_test.c \
simple_test74.c \
simple_test75.c \
simple_test76.c \
simple_test77.c \
simple_test78.c \
simple_test79.c \
simple_test80.c \
simple_test81.c \
simple_test82.c \
simple_test83.c \
simple_test84.c \
simple_test85.c \
simple_test86.c \
raminit_test1.c \
raminit_test2.c \
raminit_test3.c \
raminit_test4.c \
@ -111,6 +127,9 @@ FAIL_TESTS = \
fail_test6.c \
fail_test7.c \
fail_test8.c \
fail_test9.c \
fail_test10.c \
fail_test11.c \
TEST_SRCS:=$(patsubst %, tests/%, $(TESTS))
TEST_ASM:=$(patsubst %.c, tests/%.S, $(TESTS))
@ -128,7 +147,8 @@ TEST_ASM_O2_mmmx_msse:=$(patsubst %.c, tests/%.S-O2-mmmx-msse, $(TESTS))
TEST_ASM_O2_mmmx_call :=$(patsubst %.c, tests/%.S-O2-mmmx-call, $(TESTS))
TEST_ASM_O2_mmmx_msse_call:=$(patsubst %.c, tests/%.S-O2-mmmx-msse-call, $(TESTS))
TEST_ASM_ALL:= $(TEST_ASM) $(TEST_ASM_O) $(TEST_ASM_O2) $(TEST_ASM_mmmx) $(TEST_ASM_msse) $(TEST_ASM_mmmx_msse) $(TEST_ASM_O_mmmx) $(TEST_ASM_O_msse) $(TEST_ASM_O_mmmx_msse) $(TEST_ASM_O2_mmmx) $(TEST_ASM_O2_msse) $(TEST_ASM_O2_mmmx_msse) $(TEST_ASM_O2_mmmx_call) $(TEST_ASM_O2_mmmx_msse_call)
TEST_ASM_MOST:= $(TEST_ASM_O) $(TEST_ASM_O_mmmx) $(TEST_ASM_O_msse) $(TEST_ASM_O_mmmx_msse) $(TEST_ASM_O2) $(TEST_ASM_O2_mmmx) $(TEST_ASM_O2_msse) $(TEST_ASM_O2_mmmx_msse) $(TEST_ASM_O2_mmmx_call) $(TEST_ASM_O2_mmmx_msse_call)
TEST_ASM_MOST:= $(TEST_ASM_O) $(TEST_ASM_O_mmmx) $(TEST_ASM_O_msse) $(TEST_ASM_O_mmmx_msse) $(TEST_ASM_O2) $(TEST_ASM_O2_mmmx) $(TEST_ASM_O2_msse) $(TEST_ASM_O2_mmmx_msse)
# $(TEST_ASM_O2_mmmx_call) $(TEST_ASM_O2_mmmx_msse_call)
TEST_OBJ:=$(patsubst %.c, tests/%.o, $(TESTS))
TEST_ELF:=$(patsubst %.c, tests/%.elf, $(TESTS))
LINUX_ELF:=$(patsubst %.c, tests/%.elf, $(LINUX_TESTS))
@ -138,7 +158,7 @@ FAIL_SRCS:=$(patsubst %, tests/%, $(FAIL_TESTS))
FAIL_OUT:=$(patsubst %.c, tests/%.out, $(FAIL_TESTS))
ROMCC_OPTS=-fmax-allocation-passes=8 -fdebug-live-range-conflicts
ROMCC_OPTS=-fmax-allocation-passes=8 -fdebug-live-range-conflicts -Itests/include
$(TEST_ASM): %.S: %.c romcc
export ALLOC_CHECK_=2; ./romcc $(ROMCC_OPTS) -o $@ $< > $*.debug
@ -189,6 +209,8 @@ $(TEST_ASM_O2_mmmx_msse_call): %.S-O2-mmmx-msse-call: %.c romcc
$(FAIL_OUT): %.out: %.c romcc
export ALLOC_CHECK_=2; if ./romcc $(ROMCC_OPTS) -O2 -o $*.S $< > $*.debug 2> $@ ; then exit 1 ; else exit 0 ; fi
#$(TEST_OBJ): %.o: %.S-O2-mmmx-call
$(TEST_OBJ): %.o: %.S-O2-mmmx
as $< -o $@
@ -205,6 +227,7 @@ run_linux: $(LINUX_OUT)
echo:
echo "TEST_SRCS=$(TEST_SRCS)"
echo "TEST_ASM=$(TEST_ASM)"
echo "TEST_ASM=$(TEST_ASM_MOST)"
echo "TEST_OBJ=$(TEST_OBJ)"
echo "TEST_ELF=$(TEST_ELF)"
echo ""

96
util/romcc/do_tests.sh Normal file
View File

@ -0,0 +1,96 @@
#!/bin/sh
type="simple"
if [ -n "$1" ] ; then
type=$1
fi
if [ "$type" = "simple" ] ; then
LIST="18 57 21 79 77 40 62 52 65 78 63 81 80 64 12 8 9 7 53 58 37 35 48 11 75 51 49 41 71 23 70 16 13 24 31 55 19 69 67 66 17 28 68 61 32 33 43 60 45 47 36 10 46 15 3 29 50 56 76 34 74 25 26 27 20 1 14 73 5 4"
LIST="82 83 $LIST"
BASE="simple_test"
#REG_SKIP="34 73 5 33 45 47 25 27 26 20 "
#SKIP="$REG_SKIP"
EXPECTED_BAD="34 73 5 4"
fi
if [ "$type" = "linux" ] ; then
LIST="1 2 3 4 5 6 7 8 9 10 11 12"
BASE="linux_test"
#SKIP="5"
EXPECTED_BAD=""
fi
if [ "$type" = "raminit" ] ; then
LIST="1 2 3 4 5 6"
BASE="raminit_test"
#SKIP="6"
EXPECTED_BAD=""
fi
if [ "$type" = "hello" ] ; then
LIST="1 2"
BASE="hello_world"
EXPECTED_BAD=""
fi
SKIPPED=""
GOOD=""
BAD=""
OLD_BAD=""
NEW_BAD=""
NEW_GOOD=""
for i in $LIST ; do
DO_SKIP=""
for j in $SKIP ; do
if [ "$j" = "$i" ] ; then
DO_SKIP="yes"
break;
fi
done
if [ ! -z "$DO_SKIP" ] ; then
SKIPPED="$SKIPPED$i "
continue;
fi
PROBLEM=""
for j in $EXPECTED_BAD ; do
if [ "$j" = "$i" ] ; then
PROBLEM=":("
break;
fi
done
echo -e -n "$i $PROBLEM\t"
if ./tests.sh $BASE $i > /dev/null 2> /dev/null ; then
echo OK
if [ ! -z "$PROBLEM" ] ; then
NEW_GOOD="$NEW_GOOD$i "
fi
GOOD="$GOOD$i "
else
echo -n "FAILED: "
tail -n 1 tests/$BASE$i.debug2 | tr -d '\r\n'
echo
if [ -z "$PROBLEM" ] ; then
NEW_BAD="$NEW_BAD$i "
else
OLD_BAD="$OLD_BAD$i "
fi
BAD="$BAD$i "
fi
done
echo -e "SKIPPED\t\t$SKIPPED"
echo -e "FAILED\t\t$BAD"
if [ ! -z "$NEW_BAD" ]; then
echo -e "NEW FAILED\t$NEW_BAD"
fi
echo -e "OK\t\t$GOOD"
if [ ! -z "$NEW_GOOD" ]; then
echo -e "NEW OK\t\t$NEW_GOOD"
fi
for i in $NEW_BAD ; do
printf "%2d: " $i
tail -n 1 tests/$BASE$i.debug2 | tr -d '\n\r'
echo
done
echo "-----"
for i in $OLD_BAD ; do
printf "%2d: " $i
tail -n 1 tests/$BASE$i.debug2
done

View File

@ -0,0 +1 @@
a: 00000001 b: 00000002 c: ffffffff d: 00000007

View File

@ -0,0 +1 @@
ffffffff

View File

@ -0,0 +1,11 @@
hah?
Hi!! There
This should be shown as a string... "enclosed in quotes"
This is a quote" see
135 There
00000003
x ## y
romcc: 00.3b
linux_test12.c:test:0000003c
Compiled at: Apr 12 2004 12:06:09
Compile time: 12:06:09

View File

@ -0,0 +1,14 @@
A
1
2
3
4
2
3
4
2
4
2
4
5
B

View File

@ -0,0 +1 @@
clocks: 00000003

View File

@ -0,0 +1,134 @@
i: 0000007f
i: 00000080
i: 00000081
i: 00000082
i: 00000083
i: 00000084
i: 00000085
i: 00000086
i: 00000087
i: 00000088
i: 00000089
i: 0000008a
i: 0000008b
i: 0000008c
i: 0000008d
i: 0000008e
i: 0000008f
i: 00000090
i: 00000091
i: 00000092
i: 00000093
i: 00000094
i: 00000095
i: 00000096
i: 00000097
i: 00000098
i: 00000099
i: 0000009a
i: 0000009b
i: 0000009c
i: 0000009d
i: 0000009e
i: 0000009f
i: 000000a0
i: 000000a1
i: 000000a2
i: 000000a3
i: 000000a4
i: 000000a5
i: 000000a6
i: 000000a7
i: 000000a8
i: 000000a9
i: 000000aa
i: 000000ab
i: 000000ac
i: 000000ad
i: 000000ae
i: 000000af
i: 000000b0
i: 000000b1
i: 000000b2
i: 000000b3
i: 000000b4
i: 000000b5
i: 000000b6
i: 000000b7
i: 000000b8
i: 000000b9
i: 000000ba
i: 000000bb
i: 000000bc
i: 000000bd
i: 000000be
i: 000000bf
i: 000000c0
i: 000000c1
i: 000000c2
i: 000000c3
i: 000000c4
i: 000000c5
i: 000000c6
i: 000000c7
i: 000000c8
i: 000000c9
i: 000000ca
i: 000000cb
i: 000000cc
i: 000000cd
i: 000000ce
i: 000000cf
i: 000000d0
i: 000000d1
i: 000000d2
i: 000000d3
i: 000000d4
i: 000000d5
i: 000000d6
i: 000000d7
i: 000000d8
i: 000000d9
i: 000000da
i: 000000db
i: 000000dc
i: 000000dd
i: 000000de
i: 000000df
i: 000000e0
i: 000000e1
i: 000000e2
i: 000000e3
i: 000000e4
i: 000000e5
i: 000000e6
i: 000000e7
i: 000000e8
i: 000000e9
i: 000000ea
i: 000000eb
i: 000000ec
i: 000000ed
i: 000000ee
i: 000000ef
i: 000000f0
i: 000000f1
i: 000000f2
i: 000000f3
i: 000000f4
i: 000000f5
i: 000000f6
i: 000000f7
i: 000000f8
i: 000000f9
i: 000000fa
i: 000000fb
i: 000000fc
i: 000000fd
i: 000000fe
i: 000000ff
i: 00000000
i: 00000001
i: 00000002
i: 00000003
i: 00000004

File diff suppressed because it is too large Load Diff

67
util/romcc/tests.sh Normal file
View File

@ -0,0 +1,67 @@
#!/bin/sh
# Allow core dumps
ulimit -c hard
set -x
N=''
root=simple_test
#root=simple_test
#root=linux_test
#root=raminit_test
if [ -n "$2" -a -n "$1" ] ; then
root=$1
N=$2
elif [ -n "$1" ] ; then
root=$1
else
echo "too few arguments"
exit 1
fi
ROMCC=./romcc
stem="$root$N"
base=tests/$stem
op="-Itests/include"
op="$op -feliminate-inefectual-code -fsimplify -fscc-transform "
#op="$op -O2"
op="$op -finline-policy=defaulton"
#op="$op -finline-policy=nopenalty"
#op="$op -finline-policy=never"
op="$op -fdebug -fdebug-triples -fdebug-interference -fdebug-verification"
#op="$op -fdebug-inline"
#op="$op -fdebug-calls"
#op="$op -mnoop-copy"
#op="$op -fsimplify -fno-simplify-op -fno-simplify-phi -fno-simplify-label -fno-simplify-branch -fno-simplify-copy -fno-simplify-arith -fno-simplify-shift -fno-simplify-bitwise -fno-simplify-logical"
#op="$op -fdebug-rebuild-ssa-form"
op="$op -fmax-allocation-passes=8"
op="$op -fdebug-live-range-conflicts"
op="$op -fdebug-scc-transform"
op="$op -fdebug-scc-transform2"
#-fdebug-coalescing
#-fdebug-coalesing2
#-fno-simplify-call "
#-fno-always-inline"
#
#op="-O2 -mmmx -msse --debug=4294967295"
#op="-fdebug -fdebug-triples -fdebug-inline -O2 -mmmx -msse -fno-always-inline "
#op="-fdebug -fdebug-inline -O2 -mmmx "
#op="-fdebug -fdebug-live-range-conflicts -fdebug-live-range-conflicts2 -fno-debug-interference -fdebug-color-graph -fdebug-coalescing -fmax-allocation-passes=10 -O2 -mmmx -msse"
#op="-fdebug -O2 -mmmx -msse"
#op="-fdebug -fdebug-inline -fno-eliminate-inefectual-code -fno-always-inline -mmmx"
#op="-fdebug -fdebug-inline -fno-always-inline -mmmx"
export ALLOC_CHECK_=2
rm -f core $base.S $base.debug $base.debug2 $base.elf $base.out &&
make romcc &&
$ROMCC $op -o $base.S $base.c 2>&1 > $base.debug | tee $base.debug2
if [ '(' -f $base.c ')' -a '(' '!' -f core ')' -a '(' -f $base.S ')' ]; then
if [ "$stem" = "linux_test$N" ] ; then
as $base.S -o $base.o &&
ld -T tests/ldscript.ld $base.o -o $base.elf &&
./$base.elf > $base.out &&
diff -u results/$stem.out $base.out
else
/bin/true
fi
else
/bin/false
fi

View File

@ -0,0 +1,19 @@
struct result {
int a, b, c, d;
};
struct big_arg {
int a, b;
};
static struct result main(int a, int b, struct big_arg d)
{
struct result result;
result.a = 1;
result.b = 1;
result.c = b + 1;
result.d = a + 1;
}

View File

@ -0,0 +1,21 @@
struct big_arg {
int x, y;
};
struct result {
struct big_arg a;
int c, d;
};
static struct result main(int a, int b, int c, int d)
{
struct result result;
result.a.x = d + 1;
result.a.y = c + 1;
result.c = b + 1;
result.d = a + 1;
return result;
}

View File

@ -0,0 +1,9 @@
typedef __builtin_msr_t msr_t;
static msr_t rdmsr(unsigned long index)
{
return __builtin_rdmsr(index);
}
#warning "romcc should die gracefully here"

View File

@ -0,0 +1,128 @@
void outb(unsigned char value, unsigned short port)
{
__builtin_outb(value, port);
}
unsigned char inb(unsigned short port)
{
return __builtin_inb(port);
}
/* Base Address */
#ifndef TTYS0_BASE
#define TTYS0_BASE 0x3f8
#endif
#ifndef TTYS0_BAUD
#define TTYS0_BAUD 115200
#endif
#if ((115200%TTYS0_BAUD) != 0)
#error Bad ttys0 baud rate
#endif
#if TTYS0_BAUD == 115200
#define TTYS0_DIV (1)
#else
#define TTYS0_DIV (115200/TTYS0_BAUD)
#endif
/* Line Control Settings */
#ifndef TTYS0_LCS
/* Set 8bit, 1 stop bit, no parity */
#define TTYS0_LCS 0x3
#endif
#define UART_LCS TTYS0_LCS
/* Data */
#define UART_RBR 0x00
#define UART_TBR 0x00
/* Control */
#define UART_IER 0x01
#define UART_IIR 0x02
#define UART_FCR 0x02
#define UART_LCR 0x03
#define UART_MCR 0x04
#define UART_DLL 0x00
#define UART_DLM 0x01
/* Status */
#define UART_LSR 0x05
#define UART_MSR 0x06
#define UART_SCR 0x07
int uart_can_tx_byte(void)
{
return inb(TTYS0_BASE + UART_LSR) & 0x20;
}
void uart_wait_to_tx_byte(void)
{
while(!uart_can_tx_byte())
;
}
void uart_wait_until_sent(void)
{
while(!(inb(TTYS0_BASE + UART_LSR) & 0x40))
;
}
static void uart_tx_byte(unsigned char data)
{
uart_wait_to_tx_byte();
outb(data, TTYS0_BASE + UART_TBR);
/* Make certain the data clears the fifos */
uart_wait_until_sent();
}
void uart_init(void)
{
/* disable interrupts */
outb(0x0, TTYS0_BASE + UART_IER);
/* enable fifo's */
outb(0x01, TTYS0_BASE + UART_FCR);
/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
outb(0x80 | UART_LCS, TTYS0_BASE + UART_LCR);
outb(TTYS0_DIV & 0xFF, TTYS0_BASE + UART_DLL);
outb((TTYS0_DIV >> 8) & 0xFF, TTYS0_BASE + UART_DLM);
outb(UART_LCS, TTYS0_BASE + UART_LCR);
}
void __console_tx_char(unsigned char byte)
{
uart_tx_byte(byte);
}
void __console_tx_string(char *str)
{
unsigned char ch;
while((ch = *str++) != '\0') {
__console_tx_char(ch);
}
}
void print_debug_char(unsigned char byte) { __console_tx_char(byte); }
void print_debug(char *str) { __console_tx_string(str); }
void main(void)
{
static const char msg[] = "hello world\r\n";
uart_init();
#if 0
print_debug(msg);
#endif
#if 1
print_debug("hello world\r\n");
print_debug("how are you today\r\n");
#endif
while(1) {
;
}
}

View File

@ -0,0 +1,136 @@
#ifndef LINUX_CONSOLE_H
#define LINUX_CONSOLE_H
#include "linux_syscall.h"
static const char *addr_of_char(unsigned char ch)
{
static const char byte[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
};
return byte + ch;
}
static void console_tx_byte(unsigned char ch)
{
write(STDOUT_FILENO, addr_of_char(ch), 1);
}
static inline void console_tx_nibble(unsigned nibble)
{
unsigned char digit;
digit = nibble + '0';
if (digit > '9') {
digit += 39;
}
console_tx_byte(digit);
}
static void console_tx_char(unsigned char byte)
{
console_tx_byte(byte);
}
static void console_tx_hex8(unsigned char value)
{
console_tx_nibble((value >> 4U) & 0x0fU);
console_tx_nibble(value & 0x0fU);
}
static void console_tx_hex16(unsigned short value)
{
console_tx_nibble((value >> 12U) & 0x0FU);
console_tx_nibble((value >> 8U) & 0x0FU);
console_tx_nibble((value >> 4U) & 0x0FU);
console_tx_nibble(value & 0x0FU);
}
static void console_tx_hex32(unsigned int value)
{
console_tx_nibble((value >> 28U) & 0x0FU);
console_tx_nibble((value >> 24U) & 0x0FU);
console_tx_nibble((value >> 20U) & 0x0FU);
console_tx_nibble((value >> 16U) & 0x0FU);
console_tx_nibble((value >> 12U) & 0x0FU);
console_tx_nibble((value >> 8U) & 0x0FU);
console_tx_nibble((value >> 4U) & 0x0FU);
console_tx_nibble(value & 0x0FU);
}
static void console_tx_string(const char *str)
{
unsigned char ch;
while((ch = *str++) != '\0') {
console_tx_byte(ch);
}
}
static void print_emerg_char(unsigned char byte) { console_tx_char(byte); }
static void print_emerg_hex8(unsigned char value) { console_tx_hex8(value); }
static void print_emerg_hex16(unsigned short value){ console_tx_hex16(value); }
static void print_emerg_hex32(unsigned int value) { console_tx_hex32(value); }
static void print_emerg(const char *str) { console_tx_string(str); }
static void print_warn_char(unsigned char byte) { console_tx_char(byte); }
static void print_warn_hex8(unsigned char value) { console_tx_hex8(value); }
static void print_warn_hex16(unsigned short value){ console_tx_hex16(value); }
static void print_warn_hex32(unsigned int value) { console_tx_hex32(value); }
static void print_warn(const char *str) { console_tx_string(str); }
static void print_info_char(unsigned char byte) { console_tx_char(byte); }
static void print_info_hex8(unsigned char value) { console_tx_hex8(value); }
static void print_info_hex16(unsigned short value){ console_tx_hex16(value); }
static void print_info_hex32(unsigned int value) { console_tx_hex32(value); }
static void print_info(const char *str) { console_tx_string(str); }
static void print_debug_char(unsigned char byte) { console_tx_char(byte); }
static void print_debug_hex8(unsigned char value) { console_tx_hex8(value); }
static void print_debug_hex16(unsigned short value){ console_tx_hex16(value); }
static void print_debug_hex32(unsigned int value) { console_tx_hex32(value); }
static void print_debug(const char *str) { console_tx_string(str); }
static void print_spew_char(unsigned char byte) { console_tx_char(byte); }
static void print_spew_hex8(unsigned char value) { console_tx_hex8(value); }
static void print_spew_hex16(unsigned short value){ console_tx_hex16(value); }
static void print_spew_hex32(unsigned int value) { console_tx_hex32(value); }
static void print_spew(const char *str) { console_tx_string(str); }
static void die(const char *str)
{
print_emerg(str);
do {
asm volatile (" ");
} while(1);
}
#endif /* LINUX_CONSOLE_H */

View File

@ -0,0 +1,7 @@
#ifndef LINUX_SYSCALL_H
#define LINUX_SYSCALL_H
/* When I support other platforms use #ifdefs here */
#include "linuxi386_syscall.h"
#endif /* LINUX_SYSCALL_H */

View File

@ -0,0 +1,299 @@
struct syscall_result {
long val;
int errno;
};
static inline struct syscall_result syscall_return(long result)
{
struct syscall_result res;
if (((unsigned long)result) >= ((unsigned long)-125)) {
res.errno = - result;
res.val = -1;
} else {
res.errno = 0;
res.val = result;
}
return res;
}
static struct syscall_result syscall0(unsigned long nr)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr));
return syscall_return(res);
}
static struct syscall_result syscall1(unsigned long nr, unsigned long arg1)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1));
return syscall_return(res);
}
static struct syscall_result syscall2(unsigned long nr, unsigned long arg1, unsigned long arg2)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1), "c" (arg2));
return syscall_return(res);
}
static struct syscall_result syscall3(unsigned long nr, unsigned long arg1, unsigned long arg2,
unsigned long arg3)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3));
return syscall_return(res);
}
static struct syscall_result syscall4(unsigned long nr, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4));
return syscall_return(res);
}
static struct syscall_result syscall5(unsigned long nr, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3),
"S" (arg4), "D" (arg5));
return syscall_return(res);
}
#define NR_exit 1
#define NR_fork 2
#define NR_read 3
#define NR_write 4
#define NR_open 5
#define NR_close 6
#define NR_waitpid 7
#define NR_creat 8
#define NR_link 9
#define NR_unlink 10
#define NR_execve 11
#define NR_chdir 12
#define NR_time 13
#define NR_mknod 14
#define NR_chmod 15
#define NR_lchown 16
#define NR_break 17
#define NR_oldstat 18
#define NR_lseek 19
#define NR_getpid 20
#define NR_mount 21
#define NR_umount 22
#define NR_setuid 23
#define NR_getuid 24
#define NR_stime 25
#define NR_ptrace 26
#define NR_alarm 27
#define NR_oldfstat 28
#define NR_pause 29
#define NR_utime 30
#define NR_stty 31
#define NR_gtty 32
#define NR_access 33
#define NR_nice 34
#define NR_ftime 35
#define NR_sync 36
#define NR_kill 37
#define NR_rename 38
#define NR_mkdir 39
#define NR_rmdir 40
#define NR_dup 41
#define NR_pipe 42
#define NR_times 43
#define NR_prof 44
#define NR_brk 45
#define NR_setgid 46
#define NR_getgid 47
#define NR_signal 48
#define NR_geteuid 49
#define NR_getegid 50
#define NR_acct 51
#define NR_umount2 52
#define NR_lock 53
#define NR_ioctl 54
#define NR_fcntl 55
#define NR_mpx 56
#define NR_setpgid 57
#define NR_ulimit 58
#define NR_oldolduname 59
#define NR_umask 60
#define NR_chroot 61
#define NR_ustat 62
#define NR_dup2 63
#define NR_getppid 64
#define NR_getpgrp 65
#define NR_setsid 66
#define NR_sigaction 67
#define NR_sgetmask 68
#define NR_ssetmask 69
#define NR_setreuid 70
#define NR_setregid 71
#define NR_sigsuspend 72
#define NR_sigpending 73
#define NR_sethostname 74
#define NR_setrlimit 75
#define NR_getrlimit 76
#define NR_getrusage 77
#define NR_gettimeofday 78
#define NR_settimeofday 79
#define NR_getgroups 80
#define NR_setgroups 81
#define NR_select 82
#define NR_symlink 83
#define NR_oldlstat 84
#define NR_readlink 85
#define NR_uselib 86
#define NR_swapon 87
#define NR_reboot 88
#define NR_readdir 89
#define NR_mmap 90
#define NR_munmap 91
#define NR_truncate 92
#define NR_ftruncate 93
#define NR_fchmod 94
#define NR_fchown 95
#define NR_getpriority 96
#define NR_setpriority 97
#define NR_profil 98
#define NR_statfs 99
#define NR_fstatfs 100
#define NR_ioperm 101
#define NR_socketcall 102
#define NR_syslog 103
#define NR_setitimer 104
#define NR_getitimer 105
#define NR_stat 106
#define NR_lstat 107
#define NR_fstat 108
#define NR_olduname 109
#define NR_iopl 110
#define NR_vhangup 111
#define NR_idle 112
#define NR_vm86old 113
#define NR_wait4 114
#define NR_swapoff 115
#define NR_sysinfo 116
#define NR_ipc 117
#define NR_fsync 118
#define NR_sigreturn 119
#define NR_clone 120
#define NR_setdomainname 121
#define NR_uname 122
#define NR_modify_ldt 123
#define NR_adjtimex 124
#define NR_mprotect 125
#define NR_sigprocmask 126
#define NR_create_module 127
#define NR_init_module 128
#define NR_delete_module 129
#define NR_get_kernel_syms 130
#define NR_quotactl 131
#define NR_getpgid 132
#define NR_fchdir 133
#define NR_bdflush 134
#define NR_sysfs 135
#define NR_personality 136
#define NR_afs_syscall 137 /* Syscall for Andrew File System */
#define NR_setfsuid 138
#define NR_setfsgid 139
#define NR__llseek 140
#define NR_getdents 141
#define NR__newselect 142
#define NR_flock 143
#define NR_msync 144
#define NR_readv 145
#define NR_writev 146
#define NR_getsid 147
#define NR_fdatasync 148
#define NR__sysctl 149
#define NR_mlock 150
#define NR_munlock 151
#define NR_mlockall 152
#define NR_munlockall 153
#define NR_sched_setparam 154
#define NR_sched_getparam 155
#define NR_sched_setscheduler 156
#define NR_sched_getscheduler 157
#define NR_sched_yield 158
#define NR_sched_get_priority_max 159
#define NR_sched_get_priority_min 160
#define NR_sched_rr_get_interval 161
#define NR_nanosleep 162
#define NR_mremap 163
#define NR_setresuid 164
#define NR_getresuid 165
#define NR_vm86 166
#define NR_query_module 167
#define NR_poll 168
#define NR_nfsservctl 169
#define NR_setresgid 170
#define NR_getresgid 171
#define NR_prctl 172
#define NR_rt_sigreturn 173
#define NR_rt_sigaction 174
#define NR_rt_sigprocmask 175
#define NR_rt_sigpending 176
#define NR_rt_sigtimedwait 177
#define NR_rt_sigqueueinfo 178
#define NR_rt_sigsuspend 179
#define NR_pread 180
#define NR_pwrite 181
#define NR_chown 182
#define NR_getcwd 183
#define NR_capget 184
#define NR_capset 185
#define NR_sigaltstack 186
#define NR_sendfile 187
#define NR_getpmsg 188 /* some people actually want streams */
#define NR_putpmsg 189 /* some people actually want streams */
#define NR_vfork 190
/* Standard file descriptors */
#define STDIN_FILENO 0 /* Standard input */
#define STDOUT_FILENO 1 /* Standard output */
#define STDERR_FILENO 2 /* Standard error output */
typedef long ssize_t;
typedef unsigned long size_t;
static ssize_t write(int fd, const void *buf, size_t count)
{
struct syscall_result res;
res = syscall3(NR_write, fd, (unsigned long)buf, count);
return res.val;
}
static void _exit(int status)
{
struct syscall_result res;
res = syscall1(NR_exit, status);
}

View File

@ -4,6 +4,7 @@ ENTRY(_start)
SECTIONS
{
. = 0x1000;
__cpu_reset = 0xdeadbeef;
.text . : {
. = ALIGN(16);
_start = . ;

View File

@ -0,0 +1,57 @@
#include "linux_syscall.h"
#include "linux_console.h"
struct stuff {
signed int a : 5;
signed int b : 6;
signed int c : 2;
unsigned int d : 3;
};
static void test(void)
{
struct stuff var;
#if 0
int a, b, c, d;
a = 1;
b = 2;
c = 3;
d = 7;
var.a = a;
var.b = b;
var.c = c;
var.d = d;
a = var.a;
b = var.b;
c = var.c;
d = var.d;
print_debug(" a: ");
print_debug_hex32(a);
print_debug(" b: ");
print_debug_hex32(b);
print_debug(" c: ");
print_debug_hex32(c);
print_debug(" d: ");
print_debug_hex32(d);
#else
var.a = 1;
var.b = 2;
var.c = 3;
var.d = 7;
print_debug(" a: ");
print_debug_hex32(var.a);
print_debug(" b: ");
print_debug_hex32(var.b);
print_debug(" c: ");
print_debug_hex32(var.c);
print_debug(" d: ");
print_debug_hex32(var.d);
#endif
print_debug("\n");
_exit(0);
}

View File

@ -0,0 +1,11 @@
#include "linux_syscall.h"
#include "linux_console.h"
static void test(void)
{
signed char x;
x = -1;
print_debug_hex32(x);
print_debug("\n");
_exit(0);
}

View File

@ -0,0 +1,70 @@
#include "linux_syscall.h"
#include "linux_console.h"
#define MACRO(hello, hello2) 1
#ifndef A
#define A 135
#endif
#define B A
#define C B
#define D C
#define E D
#define F E
#define G F
#define H G
#define I H
#define FOO() "hah?\n"
#define BAR(X) ( X " There\n" )
#define BAZ(X) #X
#define SUM(X, Y) ((X) + (Y))
#define REALLY_SUM(...) SUM(__VA_ARGS__)
#define hash_hash # /* comment */ ## #
#define mkstr(a) # a
#define in_between(a) mkstr(a)
#define join(c, d) in_between(c hash_hash d)
#define ECHO(X) X
#define print_debug(X) ECHO(print_debug(X))
static void test(void)
{
print_debug(FOO());
print_debug(BAR("Hi!!"));
print_debug(BAZ(This should be shown as a string... "enclosed in quotes") "\n");
print_debug("This is a quote\" see\n");
print_debug(BAR(BAZ(I)));
print_debug_hex32(REALLY_SUM(1,2));
print_debug("\n");
print_debug(join(x, y) "\n");
print_debug("romcc: ");
print_debug_hex8(__ROMCC__);
print_debug(".");
print_debug_hex8(__ROMCC_MINOR__);
print_debug("\n");
print_debug(__FILE__);
print_debug(":");
print_debug(__func__);
print_debug(":");
print_debug_hex32(__LINE__);
print_debug("\n");
print_debug("Compiled at: ");
print_debug(__DATE__);
print_debug(" ");
print_debug(__TIME__);
print_debug("\n");
print_debug("Compile time: ");
print_debug(__TIME__);
print_debug("\n");
_exit(0);
}

View File

@ -0,0 +1,47 @@
#include "linux_syscall.h"
#include "linux_console.h"
struct mem_controller {
unsigned short channel0[4];
};
static unsigned int spd_detect_dimms(const struct mem_controller *ctrl)
{
unsigned dimm_mask;
int i;
print_debug("1\n");
dimm_mask = 0;
for(i = 0; i < 4; i++) {
int byte;
unsigned device;
print_debug("2\n");
device = ctrl->channel0[i];
if (device) {
print_debug("3\n");
byte = ctrl->channel0[i] + 2;
if (byte == 7) {
dimm_mask |= (1 << i);
}
}
print_debug("4\n");
}
print_debug("5\n");
return dimm_mask;
}
static void main(void)
{
static const struct mem_controller cpu[] = {
{
.channel0 = { (0xa<<3)|0, (0xa<<3)|2, 0, 0 },
},
};
long dimm_mask;
print_debug("A\n");
dimm_mask = spd_detect_dimms(cpu);
print_debug("B\n");
_exit(0);
}

View File

@ -1,7 +1,7 @@
#include "linux_syscall.h"
#include "linux_console.h"
int log2(int value)
inline int log2(int value)
{
/* __builtin_bsr is a exactly equivalent to the x86 machine
* instruction with the exception that it returns -1

View File

@ -0,0 +1,13 @@
#include "linux_syscall.h"
#include "linux_console.h"
static void test(void)
{
unsigned char i;
for(i = 127; i != 5; i++) {
print_debug("i: ");
print_debug_hex32((unsigned )i);
print_debug("\n");
}
_exit(0);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,252 @@
void land_test(void)
{
int i;
i = 1 && 2;
}
void lor_test(void)
{
int i;
i = 1 || 2;
}
void outb(unsigned char value, unsigned short port)
{
__builtin_outb(value, port);
}
unsigned char inb(unsigned short port)
{
return __builtin_inb(port);
}
static unsigned int config_cmd2(unsigned char bus, unsigned devfn, unsigned where)
{
return 0x80000000 | (bus << 16) | (devfn << 8) | (where & ~3) ;
}
/* Base Address */
#ifndef TTYS0_BASE
#define TTYS0_BASE 0x3f8
#endif
#ifndef TTYS0_BAUD
#define TTYS0_BAUD 115200
#endif
#if ((115200%TTYS0_BAUD) != 0)
#error Bad ttys0 baud rate
#endif
#define TTYS0_DIV (115200/TTYS0_BAUD)
/* Line Control Settings */
#ifndef TTYS0_LCS
/* Set 8bit, 1 stop bit, no parity */
#define TTYS0_LCS 0x3
#endif
#define UART_LCS TTYS0_LCS
/* Data */
#define UART_RBR 0x00
#define UART_TBR 0x00
/* Control */
#define UART_IER 0x01
#define UART_IIR 0x02
#define UART_FCR 0x02
#define UART_LCR 0x03
#define UART_MCR 0x04
#define UART_DLL 0x00
#define UART_DLM 0x01
/* Status */
#define UART_LSR 0x05
#define UART_MSR 0x06
#define UART_SCR 0x07
int uart_can_tx_byte(void)
{
return inb(TTYS0_BASE + UART_LSR) & 0x20;
}
void uart_wait_to_tx_byte(void)
{
while(!uart_can_tx_byte())
;
}
void uart_wait_until_sent(void)
{
while(!(inb(TTYS0_BASE + UART_LSR) & 0x40))
;
}
void uart_tx_byte(unsigned char data)
{
uart_wait_to_tx_byte();
outb(data, TTYS0_BASE + UART_TBR);
/* Make certain the data clears the fifos */
uart_wait_until_sent();
}
void dummy(void)
{
uart_tx_byte(5);
}
#define PIIX4_DEVFN 0x90
#define SMBUS_MEM_DEVICE_START 0x50
#define SMBUS_MEM_DEVICE_END 0x53
#define SMBUS_MEM_DEVICE_INC 1
#define PM_BUS 0
#define PM_DEVFN (PIIX4_DEVFN+3)
#define SMBUS_IO_BASE 0x1000
#define SMBHSTSTAT 0
#define SMBHSTCTL 2
#define SMBHSTCMD 3
#define SMBHSTADD 4
#define SMBHSTDAT0 5
#define SMBHSTDAT1 6
#define SMBBLKDAT 7
static void smbus_wait_until_done(void)
{
unsigned char byte;
do {
byte = inb(SMBUS_IO_BASE + SMBHSTSTAT);
}while((byte &1) == 1);
#if 1
while( (byte & ~1) == 0) {
byte = inb(SMBUS_IO_BASE + SMBHSTSTAT);
}
#endif
}
#if 0
void ifthenelse(void)
{
int i;
if (5 > 2) {
i = 1;
}
else {
i = 2;
}
i = i + 3;
}
#endif
#if 0
static int add(int left, int right)
{
{
return left + right;
}
}
#else
#if 0
static int add(int left, int right)
{
return left + right;
}
#endif
#endif
#if 0
static void assign(void)
{
int i, j;
i = j = 1;
}
#endif
#if 0
static void and(void)
{
int i, j, k;
i = 1;
j = 2;
k = i && j;
}
static void and_test(void)
{
and();
}
#endif
#if 0
#define INC_TEST 2
static void inc(void)
{
int i;
i = 5;
#if (INC_TEST == 1)
i += 7;
#endif
#if (INC_TEST == 2)
++i;
#endif
#if (INC_TEST == 3)
i++;
#endif
}
#if 0
static void inc_test(void)
{
inc();
}
#endif
#endif
#if 0
static void loop(void)
{
int i;
for(i = 0; i < 10; i++) {
;
} while(i < 10);
}
static void loop_test(void)
{
loop();
}
#endif
#if 0
static void simple(void)
{
add(1,2);
}
#endif
#if 0
static void fun(void)
{
int bar;
bar = add(1, 2);
}
#endif
#if 0
static void func(void)
{
int bar, baz;
int i;
baz = add(1, 2);
baz = add(1, 2);
bar = 1;
baz = 2;
for(i = 0; i < 10; i = i + 1) {
baz = i;
}
bar = 1 + 2 * 3;
bar = add(3, 4);
bar = add(bar, baz);
}
#endif

View File

@ -27,6 +27,6 @@ static void test(void)
const struct mem_param *param;
param = &param0;
value = 0x48;
#warning "this generates word loads instead of byte loads"
#warning "this generated word loads instead of byte loads"
clocks = (value + (param->divisor << 1) - 1)/(param->divisor << 1);
}

View File

@ -6,16 +6,10 @@ static void main(void)
{
int i;
#if 1
foo();
#endif
#if 1
foo();
#endif
for(i = 0; i < 10; i++) {
#if 1
foo();
#endif
#if 0
foo();
#endif

View File

@ -0,0 +1,88 @@
struct syscall_result {
long val;
int errno;
};
static struct syscall_result syscall_return(long result)
{
struct syscall_result res;
if (((unsigned long)result) >= ((unsigned long)-125)) {
res.errno = - result;
res.val = -1;
} else {
res.errno = 0;
res.val = result;
}
return res;
}
static struct syscall_result syscall1(unsigned long nr, unsigned long arg1)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1));
return syscall_return(res);
}
static struct syscall_result syscall3(unsigned long nr, unsigned long arg1, unsigned long arg2,
unsigned long arg3)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3));
return syscall_return(res);
}
#define NR_exit 1
#define NR_write 4
/* Standard file descriptors */
#define STDIN_FILENO 0 /* Standard input */
#define STDOUT_FILENO 1 /* Standard output */
#define STDERR_FILENO 2 /* Standard error output */
typedef long ssize_t;
typedef unsigned long size_t;
static ssize_t write(int fd, const void *buf, size_t count)
{
struct syscall_result res;
res = syscall3(NR_write, fd, (unsigned long)buf, count);
return res.val;
}
static void _exit(int status)
{
struct syscall_result res;
res = syscall1(NR_exit, status);
}
static void console_tx_string(const char *str)
{
unsigned char ch;
while(1) {
}
for(;1;) {
}
do {
} while(1);
if (1) {
}else {
}
}
static void main(void)
{
static const char msg[] = "hello world\r\n";
write(STDOUT_FILENO, msg, sizeof(msg));
_exit(0);
}

View File

@ -0,0 +1,21 @@
static void goto_test(void)
{
int i;
i = 0;
goto bottom;
{
top:
i = i + 1;
}
bottom:
if (i < 10) {
goto top;
}
;
}
static void main(void)
{
goto_test();
}

View File

@ -0,0 +1,69 @@
struct syscall_result {
long val;
int errno;
};
static struct syscall_result syscall_return(long result)
{
struct syscall_result res;
if (((unsigned long)result) >= ((unsigned long)-125)) {
res.errno = - result;
res.val = -1;
} else {
res.errno = 0;
res.val = result;
}
return res;
}
static struct syscall_result syscall1(unsigned long nr, unsigned long arg1)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1));
return syscall_return(res);
}
static struct syscall_result syscall3(unsigned long nr, unsigned long arg1, unsigned long arg2,
unsigned long arg3)
{
long res;
asm volatile(
"int $0x80"
: "=a" (res)
: "a" (nr), "b" (arg1), "c" (arg2), "d" (arg3));
return syscall_return(res);
}
#define NR_exit 1
#define NR_write 4
/* Standard file descriptors */
#define STDIN_FILENO 0 /* Standard input */
#define STDOUT_FILENO 1 /* Standard output */
#define STDERR_FILENO 2 /* Standard error output */
typedef long ssize_t;
typedef unsigned long size_t;
static ssize_t write(int fd, const void *buf, size_t count)
{
struct syscall_result res;
res = syscall3(NR_write, fd, (unsigned long)buf, count);
return res.val;
}
static void _exit(int status)
{
struct syscall_result res;
res = syscall1(NR_exit, status);
}
static void main(void)
{
static const char msg[] = "hello world\r\n";
write(STDOUT_FILENO, msg, sizeof(msg));
_exit(0);
}

View File

@ -0,0 +1,5 @@
static void main(void)
{
do {
} while(1);
}

View File

@ -0,0 +1,7 @@
static void main(void)
{
int x = 25;
do {
} while(1);
*((volatile int *)5) = x;
}

View File

@ -0,0 +1,5 @@
static void main(void)
{
do {
} while(0);
}

View File

@ -0,0 +1,13 @@
typedef __builtin_msr_t msr_t;
static msr_t rdmsr(unsigned long index)
{
return __builtin_rdmsr(index);
}
static void main(void)
{
msr_t msr;
msr = rdmsr(0x12345678);
}

View File

@ -0,0 +1,8 @@
static void main(void)
{
int i;
i = __builtin_inb(0x1234);
int j;
j = __builtin_inb(0xabcd);
}

View File

@ -0,0 +1,17 @@
struct result {
int a, b, c, d;
};
static struct result main(int a, int b, int c, int d)
{
struct result result;
result.a = d;
result.b = c;
result.c = b;
result.d = a;
return result;
}

View File

@ -0,0 +1,16 @@
struct result {
int a, b, c, d;
};
static struct result main(int a, int b, int c, int d)
{
struct result result;
result.a = d + 1;
result.b = c + 1;
result.c = b + 1;
result.d = a + 1;
return result;
}

View File

@ -0,0 +1,28 @@
struct stuff {
signed int a : 5;
signed int b : 6;
signed int c : 2;
unsigned int d : 3;
};
static void main(void)
{
struct stuff var;
volatile int a, b, c, d;
a = 1;
b = 2;
c = 3;
d = 7;
var.a = a;
var.b = b;
var.c = c;
var.d = d;
a = var.a;
b = var.b;
c = var.c;
d = var.d;
asm(" " :: "r"(a), "r"(b), "r"(c), "r"(d));
}

View File

@ -0,0 +1,51 @@
struct sub4 {
unsigned a;
unsigned b;
unsigned c;
unsigned d;
unsigned e;
unsigned f;
unsigned g;
};
struct sub3 {
unsigned a;
unsigned b;
unsigned c;
unsigned d;
unsigned e;
unsigned f;
struct sub4 s4;
};
struct sub2 {
unsigned a;
unsigned b;
unsigned c;
unsigned d;
unsigned e;
struct sub3 s3;
};
struct sub1 {
unsigned a;
unsigned b;
struct sub2 s2;
};
struct stuff {
signed int a;
signed int b;
signed int c;
unsigned int d;
struct sub1 s1;
};
static void main(void)
{
struct stuff *var;
unsigned int *foo;
var = (struct stuff *)(0x12345678);
foo = &var->d;
foo = &((*var).d);
foo = &var->s1.s2.s3.s4.g;
}

View File

@ -0,0 +1,5 @@
static void main(void)
{
asm("cpuid"
::: "eax", "ebx", "ecx", "edx");
}