├── DATESTAMP ├── arch ├── m16c │ └── TODO ├── mips │ ├── TODO │ └── order.c ├── mips64 │ ├── TODO │ └── order.c ├── pdp10 │ ├── README │ └── order.c ├── sparc64 │ └── order.c ├── i86 │ ├── TODO │ └── flocal.c ├── powerpc │ └── README ├── nova │ ├── order.c │ └── README ├── pdp7 │ └── order.c ├── m68k │ └── order.c ├── i386 │ ├── order.c │ └── flocal.c └── pdp11 │ └── order.c ├── cc ├── cpp │ ├── tests │ │ ├── res22 │ │ ├── test7 │ │ ├── test6 │ │ ├── res4 │ │ ├── res9 │ │ ├── res7 │ │ ├── test4 │ │ ├── res6 │ │ ├── test9 │ │ ├── res13 │ │ ├── res1 │ │ ├── res5 │ │ ├── res8 │ │ ├── test5 │ │ ├── test8 │ │ ├── res20 │ │ ├── test13 │ │ ├── res10 │ │ ├── test18 │ │ ├── res14 │ │ ├── test1 │ │ ├── res11 │ │ ├── res18 │ │ ├── res2 │ │ ├── res3 │ │ ├── test14 │ │ ├── res15 │ │ ├── res17 │ │ ├── test15 │ │ ├── test17 │ │ ├── res15C │ │ ├── res21 │ │ ├── test10 │ │ ├── test3 │ │ ├── test11 │ │ ├── test21 │ │ ├── test19 │ │ ├── test12 │ │ ├── test2 │ │ ├── res16 │ │ ├── res16C │ │ ├── test16 │ │ └── res12 │ └── Makefile.in ├── Makefile.in ├── cxxcom │ ├── cxxdefs.h │ └── Makefile.in ├── driver │ ├── Makefile.in │ ├── xalloc.h │ ├── xalloc.c │ ├── driver.h │ ├── strlist.h │ └── strlist.c └── cc │ └── Makefile.in ├── os ├── win32 │ ├── build_installer.bat │ ├── ccconfig.h │ ├── config.h │ └── pcc.iss ├── mirbsd │ └── ccconfig.h ├── litebsd │ └── ccconfig.h ├── openbsd │ ├── f77config.h │ └── ccconfig.h ├── midnightbsd │ └── ccconfig.h ├── sysv4 │ └── ccconfig.h ├── android │ └── ccconfig.h ├── none │ └── ccconfig.h ├── inc │ └── amd64.h ├── nextstep │ └── ccconfig.h ├── freebsd │ └── ccconfig.h ├── bsd │ └── ccconfig.h ├── dragonfly │ └── ccconfig.h ├── minix │ └── ccconfig.h ├── linux │ └── ccconfig.h ├── sunos │ └── ccconfig.h └── netbsd │ └── ccconfig.h ├── common ├── unicode.h ├── compat.h ├── unicode.c └── softfloat.h ├── .gitignore ├── f77 ├── fcom │ ├── scjdefs.h │ ├── tokens │ ├── gram.exec │ ├── ftypes.h │ ├── gram.expr │ ├── gram.io │ ├── error.c │ ├── gram.head │ └── Makefile.in ├── Makefile.in └── f77 │ └── Makefile.in ├── Makefile.in └── mip └── node.h /DATESTAMP: -------------------------------------------------------------------------------- 1 | 20231021 2 | -------------------------------------------------------------------------------- /arch/m16c/TODO: -------------------------------------------------------------------------------- 1 | * Mul/Div does not work. -------------------------------------------------------------------------------- /cc/cpp/tests/res22: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | char cbuf[sizeof "'\\U12340'"]; 4 | -------------------------------------------------------------------------------- /cc/cpp/tests/test7: -------------------------------------------------------------------------------- 1 | #define a() YES 2 | #define b() a 3 | b() 4 | b()() 5 | -------------------------------------------------------------------------------- /cc/cpp/tests/test6: -------------------------------------------------------------------------------- 1 | #define X(a,b, \ 2 | c,d) \ 3 | foo 4 | 5 | X(1,2,3,4) 6 | -------------------------------------------------------------------------------- /cc/cpp/tests/res4: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | (1) 9 | -------------------------------------------------------------------------------- /cc/cpp/tests/res9: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | ao 9 | -------------------------------------------------------------------------------- /cc/cpp/tests/res7: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | a 8 | YES 9 | -------------------------------------------------------------------------------- /cc/cpp/tests/test4: -------------------------------------------------------------------------------- 1 | #define foobar 1 2 | #define C(x,y) x##y 3 | #define D(x) (C(x,bar)) 4 | D(foo) 5 | -------------------------------------------------------------------------------- /arch/mips/TODO: -------------------------------------------------------------------------------- 1 | * Fix floating-point arguments in registers 2 | * Fix structure arguments in registers 3 | -------------------------------------------------------------------------------- /arch/mips64/TODO: -------------------------------------------------------------------------------- 1 | * Fix floating-point arguments in registers 2 | * Fix structure arguments in registers 3 | -------------------------------------------------------------------------------- /cc/cpp/tests/res6: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | foo 10 | -------------------------------------------------------------------------------- /cc/cpp/tests/test9: -------------------------------------------------------------------------------- 1 | #define C(a,b,c) a##b##c 2 | #define N(x,y) C(x,_,y) 3 | #define A_O ao 4 | N(A,O) 5 | -------------------------------------------------------------------------------- /cc/cpp/tests/res13: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | long 10 | -------------------------------------------------------------------------------- /cc/cpp/tests/res1: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | char p[] = "x ## y"; 10 | -------------------------------------------------------------------------------- /cc/cpp/tests/res5: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | int j[] = { 123, 45, 67, 89, 7 | 10, 11, 12, }; 8 | -------------------------------------------------------------------------------- /cc/cpp/tests/res8: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | 10 | (hej.s_s.s_pos) 11 | -------------------------------------------------------------------------------- /os/win32/build_installer.bat: -------------------------------------------------------------------------------- 1 | "C:\Program Files\Inno Setup 5\ISCC.exe" /DAppName="PCC" /DAppVersion="1.1.x" /DAppNameLower="pcc" pcc.iss 2 | -------------------------------------------------------------------------------- /cc/cpp/tests/test5: -------------------------------------------------------------------------------- 1 | #define t(x,y,z) x ## y ## z 2 | int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), 3 | t(10,,), t(,11,), t(,,12), t(,,) }; 4 | -------------------------------------------------------------------------------- /cc/cpp/tests/test8: -------------------------------------------------------------------------------- 1 | // test macro expansion in arguments 2 | #define s_pos s_s.s_pos 3 | #define foo(x) (x) 4 | 5 | //hej.s_pos 6 | foo(hej.s_pos) 7 | 8 | -------------------------------------------------------------------------------- /cc/cpp/tests/res20: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | # 167 "" 7 | int squares[] = (1 * 1), (2 * 2), (3 * 3), (4 * 4), (5 * 5), (6 * 6), (7 * 7), (8 * 8); 8 | -------------------------------------------------------------------------------- /cc/cpp/tests/test13: -------------------------------------------------------------------------------- 1 | 2 | #define UL long, foo 3 | #define D(I,F) I 4 | #define E(I) D(I) 5 | E(UL) 6 | 7 | #define FOO 1 8 | 9 | #if (FOO == 1) 10 | 11 | #endif /* FOO */ 12 | -------------------------------------------------------------------------------- /cc/cpp/tests/res10: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | 10 | int midiopen(int); 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | foo_optarg 19 | -------------------------------------------------------------------------------- /cc/cpp/tests/test18: -------------------------------------------------------------------------------- 1 | #define str(a) #a 2 | 3 | str(foo) 4 | str("foo") 5 | str("foo\n") 6 | str("\"foo\"") 7 | str("foo\\") 8 | str("\\\"foo") 9 | str("foo\\\\") 10 | str(foo\n) 11 | str(foo\\n) 12 | -------------------------------------------------------------------------------- /cc/cpp/tests/res14: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | AB 9 | 10 | 11 | 12 | i1(c) q p 13 | 14 | 15 | 16 | 17 | B(22,(foof bar kaka)); 18 | 19 | 20 | 21 | notable; 22 | -------------------------------------------------------------------------------- /cc/cpp/tests/test1: -------------------------------------------------------------------------------- 1 | #define hash_hash # ## # 2 | #define mkstr(a) # a 3 | #define in_between(a) mkstr(a) 4 | #define join(c, d) in_between(c hash_hash d) 5 | char p[] = join(x, y); // equivalent to 6 | // char p[] = "x ## y"; 7 | -------------------------------------------------------------------------------- /cc/cpp/tests/res11: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | 10 | a 11 | a b 12 | a b c 13 | a b c d 14 | 15 | 16 | 17 | 18 | 19 | 20 | __attribute__((__noreturn__)) 21 | 22 | 23 | 1 2 24 | -------------------------------------------------------------------------------- /cc/cpp/tests/res18: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | "foo" 8 | "\"foo\"" 9 | "\"foo\\n\"" 10 | "\"\\\"foo\\\"\"" 11 | "\"foo\\\\\"" 12 | "\"\\\\\\\"foo\"" 13 | "\"foo\\\\\\\\\"" 14 | "foo\n" 15 | "foo\\n" 16 | -------------------------------------------------------------------------------- /common/unicode.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | #ifndef _UNICODE_H 4 | #define _UNICODE_H 5 | 6 | extern long u82cp(char **q); 7 | extern void u8error(const char *fmt, ...); 8 | extern void cp2u16(long num, unsigned short *s); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /cc/cpp/tests/res2: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | # 15 "" 7 | f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); 8 | f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1)) 9 | ^m(0,1); 10 | int i[] = { 1, 23, 4, 5, }; 11 | char c[2][6] = { "hello", "" }; 12 | -------------------------------------------------------------------------------- /cc/cpp/tests/res3: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | printf("x" "1" "= %d, x" "2" "= %s", x1, x2); 15 | fputs("strncmp(\"abc\\0d\", \"abc\", '\\4') == 0" ": @\n", s); 16 | 17 | \#include "vers2.h" 18 | "hello"; 19 | "hello" ", world" 20 | -------------------------------------------------------------------------------- /cc/cpp/tests/test14: -------------------------------------------------------------------------------- 1 | #define A(x) A ## x 2 | #define AB A(B) 3 | 4 | AB 5 | 6 | #define i1(w) i2(w) p 7 | #define i2(x) i1(x) q 8 | i1(c) 9 | 10 | #undef A 11 | #define A(x,y) B(x,y) 12 | 13 | A(22,(foof 14 | bar kaka)); 15 | 16 | #define CONCAT(a, b) a ## b 17 | CONCAT(not, 18 | able); 19 | 20 | -------------------------------------------------------------------------------- /cc/cpp/tests/res15: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | do { _foo_X (); } while ( 0); 7 | 8 | 9 | do { _foo_Y (); } while ( 0); 10 | 11 | 12 | do { _foo_(); } while ( 0); 13 | 14 | 15 | 16 | 17 | (111 FIRST 111); 18 | (222 SECOND 222); 19 | (111 (222 THIRD 222) 111); 20 | (222 (111 FOURTH 111) 222); 21 | -------------------------------------------------------------------------------- /cc/cpp/tests/res17: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | testing that pp-numbers are parsed correctly 6 | 7 | 8 | 9 | 10 | 11 | 123.4e+foo 12 | 123.4f+FOO 13 | 123.4e+foo 14 | 15 | 16 | 17 | 18 | 123.4e+foo 19 | 20 | 21 | 22 | 23 | FOO.123.foo.456+FOO+789.foo 24 | 25 | 26 | 0xfaff 27 | 28 | 29 | 30 | 0xfe00 31 | 32 | 33 | 34 | 0xfeff 35 | -------------------------------------------------------------------------------- /cc/cpp/tests/test15: -------------------------------------------------------------------------------- 1 | #define FOO(x) do { _foo_ ## x (); } while (/* CONSTCOND */0) 2 | FOO(X); 3 | 4 | #define BAR FOO(Y) 5 | BAR; 6 | 7 | #define BAZ do { _foo_(); } while (/* CONSTCOND */0) 8 | BAZ; 9 | 10 | #define foo(a) (111 /*LINTED*/ a 111) 11 | #define bar(a) (222 a /*LINTED*/ 222) 12 | 13 | foo(FIRST); 14 | bar(SECOND); 15 | foo(bar(THIRD)); 16 | bar(foo(FOURTH)); 17 | -------------------------------------------------------------------------------- /cc/cpp/tests/test17: -------------------------------------------------------------------------------- 1 | testing that pp-numbers are parsed correctly 2 | 3 | #define e E 4 | #define f F 5 | #define foo FOO 6 | 7 | 123.4e+foo 8 | 123.4f+foo 9 | 12\ 10 | 3.4\ 11 | e\ 12 | +\ 13 | foo 14 | 123??/ 15 | .4??/ 16 | e??/ 17 | +??/ 18 | foo 19 | foo.123.foo.456+foo+789.foo 20 | 21 | #if 0xfaff 22 | 0xfaff 23 | #endif 24 | 25 | #if 0xfe00 26 | 0xfe00 27 | #endif 28 | 29 | #if 0xfeff 30 | 0xfeff 31 | #endif 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | config.h 2 | config.log 3 | config.status 4 | Makefile 5 | *.o 6 | *.lo 7 | *~ 8 | *.bak 9 | cc/ccom/cgram.c 10 | cc/ccom/cgram.h 11 | cc/ccom/external.c 12 | cc/ccom/external.h 13 | cc/ccom/scan.c 14 | cc/ccom/ccom 15 | cc/ccom/mkext 16 | cc/cc/cc 17 | cc/cpp/cpp 18 | cc/cxxcom/cgram.c 19 | cc/cxxcom/cgram.h 20 | cc/cxxcom/external.c 21 | cc/cxxcom/external.h 22 | cc/cxxcom/mkext 23 | cc/cxxcom/cxxcom 24 | cc/cxxcom/scan.c 25 | -------------------------------------------------------------------------------- /cc/cpp/tests/res15C: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | do { _foo_X (); } while (/* CONSTCOND */0); 7 | 8 | 9 | do { _foo_Y (); } while (/* CONSTCOND */0); 10 | 11 | 12 | do { _foo_(); } while (/* CONSTCOND */0); 13 | 14 | 15 | 16 | 17 | (111 /*LINTED*/ FIRST 111); 18 | (222 SECOND /*LINTED*/ 222); 19 | (111 /*LINTED*/ (222 THIRD /*LINTED*/ 222) 111); 20 | (222 (111 /*LINTED*/ FOURTH 111) /*LINTED*/ 222); 21 | -------------------------------------------------------------------------------- /cc/cpp/tests/res21: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | _PROTOTYPE( void __bad_assertion, (const char *_mess) ); 10 | 11 | 12 | 13 | 14 | 15 | 16 | ((sizeof(lists) / sizeof(lists[0]) == sizeof(sysroots) / sizeof(sysroots[0]))? (void)0 : __bad_assertion("Assertion \"" "sizeof(lists) / sizeof(lists[0]) == sizeof(sysroots) / sizeof(sysroots[0])" "\" failed, file " "\"\"" ", line " "12" "\n")); 17 | -------------------------------------------------------------------------------- /cc/cpp/tests/test10: -------------------------------------------------------------------------------- 1 | #define __CONCAT(x,y) x ## y 2 | #define dev_type_open(n) int n(int) 3 | #define dev_decl(n,t) __CONCAT(dev_type_,t)(__CONCAT(n,t)) 4 | #define cdev_decl(n) dev_decl(n,open) 5 | 6 | cdev_decl(midi); 7 | 8 | # define __GETOPT_PREFIX foo_ 9 | # define __GETOPT_CONCAT(x, y) x ## y 10 | # define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) 11 | # define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) 12 | # define optarg __GETOPT_ID (optarg) 13 | 14 | optarg 15 | -------------------------------------------------------------------------------- /cc/cpp/tests/test3: -------------------------------------------------------------------------------- 1 | #define str(s) # s 2 | #define xstr(s) str(s) 3 | #define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \ 4 | x ## s, x ## t) 5 | #define INCFILE(n) vers ## n 6 | #define glue(a, b) a ## b 7 | #define xglue(a, b) glue(a, b) 8 | #define HIGHLOW "hello" 9 | #define LOW LOW ", world" 10 | debug(1, 2); 11 | fputs(str(strncmp("abc\0d", "abc", '\4') // this goes away 12 | == 0) str(: @\n), s); 13 | \#include xstr(INCFILE(2).h) 14 | glue(HIGH, LOW); 15 | xglue(HIGH, LOW) 16 | -------------------------------------------------------------------------------- /cc/cpp/tests/test11: -------------------------------------------------------------------------------- 1 | #define D1(s, ...) s 2 | #define D2(s, ...) s D1(__VA_ARGS__) 3 | #define D3(s, ...) s D2(__VA_ARGS__) 4 | #define D4(s, ...) s D3(__VA_ARGS__) 5 | 6 | D1(a) 7 | D2(a, b) 8 | D3(a, b, c) 9 | D4(a, b, c, d) 10 | 11 | 12 | #define __sun_attr___noreturn__ __attribute__((__noreturn__)) 13 | #define ___sun_attr_inner(__a) __sun_attr_##__a 14 | #define __sun_attr__(__a) ___sun_attr_inner __a 15 | #define __NORETURN __sun_attr__((__noreturn__)) 16 | __NORETURN 17 | #define X(...) 18 | #define Y(...) 1 __VA_ARGS__ 2 19 | Y(X X() ()) 20 | 21 | -------------------------------------------------------------------------------- /cc/cpp/tests/test21: -------------------------------------------------------------------------------- 1 | 2 | #define __makestr(x) # x 3 | #define __xstr(x) __makestr(x) 4 | 5 | _PROTOTYPE( void __bad_assertion, (const char *_mess) ); 6 | #define assert(expr) ((expr)? (void)0 : \ 7 | __bad_assertion("Assertion \"" #expr \ 8 | "\" failed, file " __xstr(__FILE__) \ 9 | ", line " __xstr(__LINE__) "\n")) 10 | 11 | 12 | assert(sizeof(lists) / sizeof(lists[0]) == 13 | sizeof(sysroots) / sizeof(sysroots[0])); 14 | 15 | -------------------------------------------------------------------------------- /cc/cpp/tests/test19: -------------------------------------------------------------------------------- 1 | #define S(x) S0(x) 2 | #define S0(x) #x 3 | #define T(x,y)\ 4 | S(x)\ 5 | S(y) 6 | #define T0(x,y)\ 7 | S0(x)\ 8 | S0(y) 9 | #define U(x)\ 10 | S(x)\ 11 | S(x) 12 | #define U0(x)\ 13 | S0(x)\ 14 | S0(x) 15 | #define V(x)\ 16 | V_(x)\ 17 | V_(x) 18 | #define V_(x)\ 19 | S(x) 20 | #define V0(x)\ 21 | V0_(x)\ 22 | V0_(x) 23 | #define V0_(x)\ 24 | S0(x) 25 | __COUNTER__ 26 | S(__COUNTER__) 27 | S0(__COUNTER__) 28 | T(__COUNTER__,__COUNTER__) 29 | T0(__COUNTER__,__COUNTER__) 30 | U(__COUNTER__) 31 | U0(__COUNTER__) 32 | V(__COUNTER__) 33 | V0(__COUNTER__) 34 | -------------------------------------------------------------------------------- /cc/cpp/tests/test12: -------------------------------------------------------------------------------- 1 | #define y 2 2 | #define fe(p) sfe(p) p 3 | #define sfe(p) p 4 | #define Y fe(y) y fe(y) 5 | 6 | Y; 7 | 8 | # define S2B_QMIN 0 9 | # define S2B_CMIN (S2B_QMIN + 8) 10 | #define S2B_1(i) i, 11 | #define S2B_2(i) S2B_1(i) S2B_1(i) 12 | #define S2B_4(i) S2B_2(i) S2B_2(i) 13 | #define S2B_8(i) S2B_4(i) S2B_4(i) 14 | #define S2B_16(i) S2B_8(i) S2B_8(i) 15 | #define S2B_32(i) S2B_16(i) S2B_16(i) 16 | #define S2B_64(i) S2B_32(i) S2B_32(i) 17 | #define S2B_128(i) S2B_64(i) S2B_64(i) 18 | #define S2B_256(i) S2B_128(i) S2B_128(i) 19 | S2B_256(S2B_CMIN + 0) 20 | -------------------------------------------------------------------------------- /cc/cpp/tests/test2: -------------------------------------------------------------------------------- 1 | #define x 3 2 | #define f(a) f(x * (a)) 3 | #undef x 4 | #define x 2 5 | #define g f 6 | #define z z[0] 7 | #define h g(~ 8 | #define m(a) a(w) 9 | #define w 0,1 10 | #define t(a) a 11 | #define p() int 12 | #define q(x) x 13 | #define r(x,y) x ## y 14 | #define str(x) # x 15 | f(y+1) + f(f(z)) % t(t(g)(0) + t)(1); 16 | g(x+(3,4)-w) | h 5) & m 17 | (f)^m(m); 18 | p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) }; 19 | char c[2][6] = { str(hello), str() }; 20 | /* 21 | * f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); 22 | * f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1); 23 | * int i[] = { 1, 23, 4, 5, }; 24 | * char c[2][6] = { "hello", "" }; 25 | */ 26 | -------------------------------------------------------------------------------- /f77/fcom/scjdefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Map pass2 nodes to pass1 dito. 3 | */ 4 | #include "node.h" 5 | 6 | 7 | #define P2BAD -1 8 | #define P2PLUS PLUS 9 | #define P2MINUS MINUS 10 | #define P2NEG UMINUS 11 | #define P2STAR MUL 12 | #define P2BITAND AND 13 | #define P2BITOR OR 14 | #define P2BITXOR ER 15 | #define P2GOTO GOTO 16 | #define P2ASSIGN ASSIGN 17 | #define P2SLASH DIV 18 | #define P2MOD MOD 19 | #define P2LSHIFT LS 20 | #define P2RSHIFT RS 21 | #define P2CALL CALL 22 | #define P2CALL0 UCALL 23 | 24 | #define P2BITNOT -1 25 | #define P2EQ EQ 26 | #define P2NE NE 27 | #define P2LE LE 28 | #define P2LT LT 29 | #define P2GE GE 30 | #define P2GT GT 31 | #define P2CONV SCONV 32 | 33 | /* special operators included only for fortran's use */ 34 | 35 | #define P2INT INT 36 | 37 | #define P2PTR PTR 38 | -------------------------------------------------------------------------------- /f77/Makefile.in: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Makefile.in for top-level of pcc. 4 | # 5 | 6 | @SET_MAKE@ 7 | 8 | ALL_SUBDIRS= f77 fcom 9 | DIST_SUBDIRS= $(ALL_SUBDIRS) 10 | 11 | all install clean: 12 | @for subdir in $(ALL_SUBDIRS); do \ 13 | _nextdir_=$${_thisdir_+$$_thisdir_/}$$subdir; \ 14 | echo "===> $$_nextdir_"; \ 15 | (_thisdir_=$$_nextdir_; export _thisdir_; cd $$subdir && \ 16 | exec $(MAKE) $(MFLAGS) $@) || exit $$?; \ 17 | echo "<=== $$_nextdir_"; \ 18 | done 19 | 20 | distclean: 21 | @for subdir in $(DIST_SUBDIRS); do \ 22 | _nextdir_=$${_thisdir_+$$_thisdir_/}$$subdir; \ 23 | echo "===> $$_nextdir_"; \ 24 | (_thisdir_=$$_nextdir_; export _thisdir_; cd $$subdir && \ 25 | exec $(MAKE) $(MFLAGS) $@) || exit $$?; \ 26 | echo "<=== $$_nextdir_"; \ 27 | done 28 | rm -f Makefile 29 | -------------------------------------------------------------------------------- /arch/pdp10/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | PDP10 C calling convention 4 | -------------------------- 5 | Register 1-7 are argument registers. Types of sizes up to 36 bits are 6 | given in one register, two otherwise. CHAR and SHORT are given as INTs. 7 | 8 | If the argument that would end up in register 7 requires two registers, 9 | it is saved on the stack instead and no more registers would end up 10 | on the stack. 11 | 12 | struct return: a hidden argument containing the address of the struct 13 | is stored as the first argument _on_the_stack_, never in register. 14 | 15 | struct argument: always saved on stack, and terminates the list 16 | of arguments that are kept in registers. 17 | 18 | In case of debugging all arguments are saved on stack in the function. 19 | 20 | All variadic arguments are always saved on the stack. 21 | -------------------------------------------------------------------------------- /cc/Makefile.in: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Makefile.in for top-level of pcc. 4 | # 5 | 6 | @SET_MAKE@ 7 | 8 | ALL_SUBDIRS= cc cpp ccom cxxcom 9 | DIST_SUBDIRS= $(ALL_SUBDIRS) driver 10 | 11 | all install clean: 12 | @for subdir in $(ALL_SUBDIRS); do \ 13 | _nextdir_=$${_thisdir_+$$_thisdir_/}$$subdir; \ 14 | echo "===> $$_nextdir_"; \ 15 | (_thisdir_=$$_nextdir_; export _thisdir_; cd $$subdir && \ 16 | exec $(MAKE) $(MFLAGS) $@) || exit $$?; \ 17 | echo "<=== $$_nextdir_"; \ 18 | done 19 | 20 | distclean: 21 | @for subdir in $(DIST_SUBDIRS); do \ 22 | _nextdir_=$${_thisdir_+$$_thisdir_/}$$subdir; \ 23 | echo "===> $$_nextdir_"; \ 24 | (_thisdir_=$$_nextdir_; export _thisdir_; cd $$subdir && \ 25 | exec $(MAKE) $(MFLAGS) $@) || exit $$?; \ 26 | echo "<=== $$_nextdir_"; \ 27 | done 28 | rm -f Makefile 29 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Makefile.in for top-level of pcc. 4 | # 5 | 6 | @SET_MAKE@ 7 | 8 | ALL_SUBDIRS= cc 9 | DIST_SUBDIRS= $(ALL_SUBDIRS) f77 10 | 11 | all install clean: 12 | @for subdir in $(ALL_SUBDIRS); do \ 13 | _nextdir_=$${_thisdir_+$$_thisdir_/}$$subdir; \ 14 | echo "===> $$_nextdir_"; \ 15 | (_thisdir_=$$_nextdir_; export _thisdir_; cd $$subdir && \ 16 | exec $(MAKE) $(MFLAGS) $@) || exit $$?; \ 17 | echo "<=== $$_nextdir_"; \ 18 | done 19 | 20 | distclean: 21 | @for subdir in $(DIST_SUBDIRS); do \ 22 | _nextdir_=$${_thisdir_+$$_thisdir_/}$$subdir; \ 23 | echo "===> $$_nextdir_"; \ 24 | (_thisdir_=$$_nextdir_; export _thisdir_; cd $$subdir && \ 25 | exec $(MAKE) $(MFLAGS) $@) || exit $$?; \ 26 | echo "<=== $$_nextdir_"; \ 27 | done 28 | rm -rf Makefile config.log stamp-h1 config.status \ 29 | configure.lineno config.h autom4te.cache 30 | -------------------------------------------------------------------------------- /common/compat.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Just compatibility function prototypes. 5 | * Public domain. 6 | */ 7 | 8 | #ifndef COMPAT_H 9 | #define COMPAT_H 10 | 11 | #ifndef HAVE_STRLCPY 12 | #include /* size_t */ 13 | size_t strlcpy(char *dst, const char *src, size_t siz); 14 | #endif 15 | 16 | #ifndef HAVE_STRLCAT 17 | #include /* size_t */ 18 | size_t strlcat(char *dst, const char *src, size_t siz); 19 | #endif 20 | 21 | #ifndef HAVE_GETOPT 22 | extern char *optarg; 23 | extern int optind; 24 | int getopt(int, char * const [], const char *); 25 | #endif 26 | 27 | #ifndef HAVE_MKSTEMP 28 | int mkstemp(char *); 29 | #endif 30 | 31 | #ifndef HAVE_FFS 32 | int ffs(int); 33 | #endif 34 | 35 | #ifndef HAVE_SNPRINTF 36 | #include /* size_t */ 37 | int snprintf(char *str, size_t count, const char *fmt, ...); 38 | #endif 39 | 40 | #ifndef HAVE_VSNPRINTF 41 | #include /* size_t */ 42 | #include /* va_list */ 43 | int vsnprintf(char *str, size_t count, const char *fmt, va_list args); 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /f77/fcom/tokens: -------------------------------------------------------------------------------- 1 | SEOS 2 | SCOMMENT 3 | SLABEL 4 | SUNKNOWN 5 | SHOLLERITH 6 | SICON 7 | SRCON 8 | SDCON 9 | SBITCON 10 | SOCTCON 11 | SHEXCON 12 | STRUE 13 | SFALSE 14 | SFNAME 15 | SNAMEEQ 16 | SFIELD 17 | SSCALE 18 | SINCLUDE 19 | SLET 20 | SASSIGN 21 | SAUTOMATIC 22 | SBACKSPACE 23 | SBLOCK 24 | SCALL 25 | SCHARACTER 26 | SCLOSE 27 | SCOMMON 28 | SCOMPLEX 29 | SCONTINUE 30 | SDATA 31 | SDCOMPLEX 32 | SDIMENSION 33 | SDO 34 | SDOUBLE 35 | SELSE 36 | SELSEIF 37 | SEND 38 | SENDFILE 39 | SENDIF 40 | SENTRY 41 | SEQUIV 42 | SEXTERNAL 43 | SFORMAT 44 | SFUNCTION 45 | SGOTO 46 | SASGOTO 47 | SCOMPGOTO 48 | SARITHIF 49 | SLOGIF 50 | SIMPLICIT 51 | SINQUIRE 52 | SINTEGER 53 | SINTRINSIC 54 | SLOGICAL 55 | SOPEN 56 | SPARAM 57 | SPAUSE 58 | SPRINT 59 | SPROGRAM 60 | SPUNCH 61 | SREAD 62 | SREAL 63 | SRETURN 64 | SREWIND 65 | SSAVE 66 | SSTATIC 67 | SSTOP 68 | SSUBROUTINE 69 | STHEN 70 | STO 71 | SUNDEFINED 72 | SWRITE 73 | SLPAR 74 | SRPAR 75 | SEQUALS 76 | SCOLON 77 | SCOMMA 78 | SCURRENCY 79 | SPLUS 80 | SMINUS 81 | SSTAR 82 | SSLASH 83 | SPOWER 84 | SCONCAT 85 | SAND 86 | SOR 87 | SNEQV 88 | SEQV 89 | SNOT 90 | SEQ 91 | SLT 92 | SGT 93 | SLE 94 | SGE 95 | SNE 96 | -------------------------------------------------------------------------------- /cc/cpp/tests/res16: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | This file is testing line counting in various scenarios involving 6 | escaped newlines, including using the trigraph escape sequence 7 | 8 | --> 4 4 9 | "multi-line string" 10 | 11 | 12 | --> 8 8 13 | 'multi-line character constant' 14 | 15 | 16 | --> 12 12 17 | multi-line 012345678 integer constant 18 | 19 | 20 | 21 | --> 17 17 22 | multi-line list of tokens 23 | 24 | 25 | 26 | 27 | 28 | --> 24 24 29 | 30 | 31 | 32 | --> 28 28 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | --> 36 36 41 | 42 | 43 | 44 | --> 40 40 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | --> 48 48 53 | 54 | #pragma multi-line #pragma directive 55 | # 49 "" 56 | 57 | 58 | 59 | --> 52 52 60 | 61 | 62 | 63 | 64 | --> 57 57 65 | multi-line macro embedded 66 | --> 59 59 67 | 68 | 69 | 70 | 71 | --> 64 64 72 | macro with a leading comment 73 | --> 66 66 74 | 75 | 76 | 77 | --> 70 70 78 | macro with leading whitespace and escaped newlines 79 | --> 72 72 80 | 81 | a token split by escaped newlines 82 | 83 | 84 | --> 77 77 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | #pragma multi-line #pragma inside if-true block 93 | # 84 "" 94 | 95 | 96 | 97 | --> 87 87 98 | 99 | --> 89 89 100 | 101 | #pragma with a preceding comment 102 | # 90 "" 103 | 104 | --> 91 91 105 | 106 | 107 | 108 | 109 | 110 | --> 97 97 111 | -------------------------------------------------------------------------------- /os/win32/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Currently only supports console applications. 5 | */ 6 | 7 | #if defined(MSLINKER) 8 | /* requires microsoft toolkit headers and linker, and pcc-libs */ 9 | #define CPPADD { "-DWIN32", "-D_WIN32", NULL } 10 | #define DEFLIBS { "/subsystem:console", "msvcrt.lib", "libpcc.a", NULL } 11 | #else 12 | /* common cpp predefines */ 13 | #define CPPADD { "-DWIN32", "-D_WIN32", "-D__MSVCRT__", "-D__MINGW32__", NULL } 14 | 15 | /* host-dependent */ 16 | /* requires w32api-3.2.tar.gz and mingw-runtime-3.14.tar.gz */ 17 | #define CRT0 "crt2.o" 18 | #define STARTLABEL "_mainCRTStartup" 19 | #define CRT0_S "dllcrt2.o" 20 | #define STARTLABEL_S "_DllMainCRTStartup@12" 21 | #define GCRT0 "gcrt2.o" /* in _addition_ to either crt2.o or dllcrt2.o */ 22 | 23 | #define CRTBEGIN 0 /* No constructor/destructor support for now */ 24 | #define CRTEND 0 25 | #define CRTBEGIN_S 0 26 | #define CRTEND_S 0 27 | #define CRTBEGIN_T 0 /* Note: MingW cannot do -static linking */ 28 | #define CRTEND_T 0 29 | #define CRTI 0 30 | #define CRTN 0 31 | 32 | #define WIN32_LIBC "-lmsvcrt" 33 | #define MINGW_RTLIBS "-lmoldname", "-lmingwex", "-lmingw32" 34 | #define MINGW_SYSLIBS "-luser32", "-lkernel32" /* ,"-ladvapi32", "-lshell32" */ 35 | #define DEFLIBS { MINGW_RTLIBS, "-lpcc", WIN32_LIBC, MINGW_SYSLIBS, MINGW_RTLIBS, WIN32_LIBC, 0 } 36 | #define DEFPROFLIBS { MINGW_RTLIBS, "-lpcc", WIN32_LIBC, "-lgmon", MINGW_SYSLIBS, MINGW_RTLIBS, WIN32_LIBC, 0 } 37 | #define DEFCXXLIBS { "-lp++", MINGW_RTLIBS, "-lpcc", WIN32_LIBC, MINGW_SYSLIBS, MINGW_RTLIBS, WIN32_LIBC, 0 } 38 | 39 | #endif 40 | 41 | #define CPPMDADD { "-D__i386__", NULL } 42 | -------------------------------------------------------------------------------- /cc/cxxcom/cxxdefs.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | enum { NM_NEW, NM_NWA, NM_DEL, NM_DLA, NM_NORMAL, }; 4 | 5 | enum { LINK_DEF, LINK_C }; /* linkage definitions */ 6 | extern int elnk; 7 | #define SCLINK 00020 /* for symtab */ 8 | 9 | extern int cppdebug; 10 | 11 | /* spole is symbol at base, nscur is where we are in the stack. */ 12 | extern struct symtab *spole, *nscur; 13 | 14 | /* insert a symbol into this something */ 15 | #define INSSYM(sp) (sp->snext = nscur->sup, nscur->sup = sp, sp->sdown = nscur) 16 | #define POPSYM() (nscur = nscur->sdown) 17 | 18 | /* C++-specific node types */ 19 | #define CONST_CAST (MAXOP+35) 20 | #define DYN_CAST (MAXOP+36) 21 | #define REINT_CAST (MAXOP+37) 22 | #define STATIC_CAST (MAXOP+38) 23 | #define NEWKW (MAXOP+39) 24 | #define DELETE (MAXOP+40) 25 | #define NMLIST (MAXOP+41) 26 | 27 | /* C++-specific symtab types */ 28 | #define CLNAME (MAXSTCL+1) /* symtab entry is class */ 29 | #define NSPACE (MAXSTCL+2) /* symtab entry is namespace */ 30 | 31 | char *decoratename(struct symtab *sp, int type); 32 | NODE *cxx_new(NODE *p); 33 | NODE *cxx_delete(NODE *p, int del); 34 | void dclns(NODE *attr, char *n); 35 | struct symtab *cxxlookup(NODE *p, int declare); 36 | void cxxsetname(struct symtab *sp); 37 | void cxxmember(struct symtab *sp); 38 | struct symtab *cxxstrvar(struct symtab *so); 39 | struct symtab *cxxdclstr(char *n); 40 | struct symtab *cxxftnfind(NODE *p, int flags); 41 | struct symtab *cxxdeclvar(NODE *p); 42 | void symtree(void); 43 | NODE *cxxrstruct(int soru, NODE *attr, NODE *t, char *tag); 44 | NODE *cxxmatchftn(NODE *, NODE *); 45 | NODE *cxxaddhidden(NODE *, NODE *); 46 | NODE *cxxstructref(NODE *p, int f, char *name); 47 | -------------------------------------------------------------------------------- /cc/cpp/tests/res16C: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | This file is testing line counting in various scenarios involving 6 | escaped newlines, including using the trigraph escape sequence 7 | 8 | --> 4 4 9 | "multi-line string" 10 | 11 | 12 | --> 8 8 13 | 'multi-line character constant' 14 | 15 | 16 | --> 12 12 17 | multi-line 012345678 integer constant 18 | 19 | 20 | 21 | --> 17 17 22 | multi-line list of tokens 23 | 24 | 25 | 26 | 27 | 28 | --> 24 24 29 | /* multi-line comment */ 30 | 31 | 32 | --> 28 28 33 | /*/ comment with escaped newlines /* 34 | 35 | 36 | in the markers 37 | */ 38 | 39 | 40 | --> 36 36 41 | // multi-line C++ comment 42 | 43 | 44 | --> 40 40 45 | // C++ comment with leading whitespace and escaped newlines 46 | 47 | 48 | 49 | 50 | 51 | 52 | --> 48 48 53 | 54 | #pragma multi-line #pragma directive 55 | # 49 "" 56 | 57 | 58 | 59 | --> 52 52 60 | 61 | 62 | 63 | 64 | --> 57 57 65 | multi-line macro /* with a comment */ embedded 66 | --> 59 59 67 | /* comment before directive */ #define BAR macro with a leading comment 68 | 69 | 70 | 71 | --> 64 64 72 | BAR 73 | --> 66 66 74 | 75 | 76 | 77 | --> 70 70 78 | macro with leading whitespace and escaped newlines 79 | --> 72 72 80 | 81 | a token split by escaped newlines 82 | 83 | 84 | --> 77 77 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | #pragma multi-line #pragma inside if-true block 93 | # 84 "" 94 | 95 | 96 | 97 | --> 87 87 98 | 99 | --> 89 89 100 | /* comment */ # pragma with a preceding comment 101 | --> 91 91 102 | 103 | 104 | 105 | 106 | 107 | --> 97 97 108 | -------------------------------------------------------------------------------- /cc/driver/Makefile.in: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Makefile.in for the cc driver part of pcc. 4 | # 5 | VPATH=@srcdir@ 6 | srcdir=@srcdir@ 7 | top_srcdir=@top_srcdir@ 8 | top_builddir=@top_builddir@ 9 | prefix = @prefix@ 10 | exec_prefix = @exec_prefix@ 11 | bindir = @bindir@ 12 | libdir = @libdir@ 13 | libexecdir = @libexecdir@ 14 | includedir = @includedir@ 15 | datarootdir = @datarootdir@ 16 | mandir = @mandir@ 17 | CC = @CC@ 18 | EXEEXT = @EXEEXT@ 19 | TARGOS = @targos@ 20 | TARGOSVER = @targosver@ 21 | TARGMACH = @targmach@ 22 | TARGET = @target@ 23 | VERSION = @PACKAGE_VERSION@ 24 | PCCLIBDIR = $(libdir)/pcc/$(TARGET)/$(VERSION)/lib 25 | PCCINCDIR = $(libdir)/pcc/$(TARGET)/$(VERSION)/include 26 | CFLAGS = @CFLAGS@ @ADD_CFLAGS@ 27 | CPPFLAGS = @CPPFLAGS@ -DLIBEXECDIR=\"$(libexecdir)/\" \ 28 | @ADD_CPPFLAGS@ -DINCLUDEDIR=\"$(includedir)/\" \ 29 | -DPCCINCDIR=\"$(PCCINCDIR)/\" -DPCCLIBDIR=\"$(PCCLIBDIR)/\" \ 30 | -DTARGOS=\"$(TARGOS)\" -DTARGOSVER=$(TARGOSVER) -Dos_$(TARGOS) \ 31 | -DTARGMACH=\"$(TARGMACH)\" -Dmach_$(TARGMACH) \ 32 | -I$(top_builddir) -I$(top_srcdir)/os/$(TARGOS) -I$(MIPDIR) -I$(MDIR) 33 | LIBS = @LIBS@ 34 | LDFLAGS = @LDFLAGS@ 35 | INSTALL = @INSTALL@ 36 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 37 | INSTALL_DATA = @INSTALL_DATA@ 38 | 39 | OBJS=driver.o platform.o strlist.o xalloc.o 40 | DEST=@BINPREFIX@pcc$(EXEEXT) 41 | 42 | MIPDIR=$(top_srcdir)/mip 43 | MDIR=$(top_srcdir)/arch/$(TARGMACH) 44 | 45 | all: $(DEST) 46 | 47 | $(DEST): $(OBJS) 48 | $(CC) $(LDFLAGS) $(OBJS) -o $@ $(LIBS) 49 | 50 | .c.o: 51 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< 52 | 53 | install: 54 | test -z "$(DESTDIR)$(bindir)" || mkdir -p "$(DESTDIR)$(bindir)" 55 | $(INSTALL_PROGRAM) $(DEST) $(DESTDIR)$(bindir) 56 | 57 | clean: 58 | rm -f $(OBJS) $(DEST) 59 | 60 | distclean: clean 61 | rm -f Makefile 62 | -------------------------------------------------------------------------------- /cc/driver/xalloc.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /*- 4 | * Copyright (c) 2011 Joerg Sonnenberger . 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef XALLOC_H 33 | #define XALLOC_H 34 | 35 | #include 36 | 37 | void *xcalloc(size_t, size_t); 38 | void *xmalloc(size_t); 39 | void *xrealloc(void *, size_t); 40 | char *xstrdup(const char *); 41 | 42 | #endif /* XALLOC_H */ 43 | -------------------------------------------------------------------------------- /os/mirbsd/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /*- 3 | * Copyright (c) 2007, 2008 4 | * Thorsten Glaser 5 | * 6 | * Provided that these terms and disclaimer and all copyright notices 7 | * are retained or reproduced in an accompanying document, permission 8 | * is granted to deal in this work without restriction, including un- 9 | * limited rights to use, publicly perform, distribute, sell, modify, 10 | * merge, give away, or sublicence. 11 | * 12 | * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 13 | * the utmost extent permitted by applicable law, neither express nor 14 | * implied; without malicious intent or gross negligence. In no event 15 | * may a licensor, author or contributor be held liable for indirect, 16 | * direct, other damage, loss, or other issues arising in any way out 17 | * of dealing in the work, even if advised of the possibility of such 18 | * damage or existence of a defect, except proven that it results out 19 | * of said person's immediate fault when using the work as intended. 20 | */ 21 | 22 | /** 23 | * Configuration for pcc on a MirOS BSD (i386 or sparc) target 24 | */ 25 | 26 | /* === mi part === */ 27 | 28 | /* cpp MI defines */ 29 | #define CPPADD { \ 30 | "-D__MirBSD__", \ 31 | "-D__OpenBSD__", \ 32 | "-D__unix__", \ 33 | "-D__ELF__", \ 34 | NULL \ 35 | } 36 | 37 | /* for dynamically linked binaries */ 38 | #define DYNLINKLIB "/usr/libexec/ld.so" 39 | 40 | #define CRTEND_T "crtend.o" 41 | #define DEFLIBS { "-lc", NULL } 42 | 43 | /* === md part === */ 44 | 45 | #if defined(mach_i386) 46 | #define CPPMDADD { \ 47 | "-D__i386__", \ 48 | "-D__i386", \ 49 | "-Di386", \ 50 | NULL, \ 51 | } 52 | #elif defined(mach_sparc) 53 | #error pcc does not support sparc yet 54 | #else 55 | #error this architecture is not supported by MirOS BSD 56 | #endif 57 | -------------------------------------------------------------------------------- /cc/cpp/tests/test16: -------------------------------------------------------------------------------- 1 | This file is testing line counting in various scenarios involving 2 | escaped newlines, including using the trigraph escape sequence 3 | 4 | --> __LINE__ 4 5 | "multi-\ 6 | line ??/ 7 | string" 8 | --> __LINE__ 8 9 | 'multi-\ 10 | line ??/ 11 | character constant' 12 | --> __LINE__ 12 13 | multi-\ 14 | line 012\ 15 | 345??/ 16 | 678 integer constant 17 | --> __LINE__ 17 18 | multi-\ 19 | line\ 20 | li??/ 21 | st ??/ 22 | of \ 23 | tokens 24 | --> __LINE__ 24 25 | /* multi-\ 26 | line ??/ 27 | comment */ 28 | --> __LINE__ 28 29 | /\ 30 | ??/ 31 | */ comment with escaped newlines /* 32 | in the markers 33 | ??/ 34 | *\ 35 | / 36 | --> __LINE__ 36 37 | // multi-\ 38 | line ??/ 39 | C++ comment 40 | --> __LINE__ 40 41 | \ 42 | \ 43 | /\ 44 | ??/ 45 | \ 46 | / ??/ 47 | C++ comment with leading whitespace and escaped newlines 48 | --> __LINE__ 48 49 | #pragma multi-\ 50 | line ??/ 51 | #pragma directive 52 | --> __LINE__ 52 53 | #define FOO multi-\ 54 | line macro /* with\ 55 | a comment *??/ 56 | / embedded 57 | --> __LINE__ 57 58 | FOO 59 | --> __LINE__ 59 60 | /??/ 61 | * comment \ 62 | before ??/ 63 | directive */ #define BAR macro with a leading comment 64 | --> __LINE__ 64 65 | BAR 66 | --> __LINE__ 66 67 | \ 68 | ??/ 69 | #define BAZ macro with leading whitespace and escaped newlines 70 | --> __LINE__ 70 71 | BAZ 72 | --> __LINE__ 72 73 | #define POTATO a token split by escaped newlines 74 | PO\ 75 | TA??/ 76 | TO 77 | --> __LINE__ 77 78 | #if 0 79 | #pragma multi-??/ 80 | line \ 81 | #pragma inside if-false block 82 | --> __LINE__ 82 83 | #else 84 | #pragma multi-??/ 85 | line \ 86 | #pragma inside if-true block 87 | --> __LINE__ 87 88 | #endif 89 | --> __LINE__ 89 90 | /* comment */ # pragma with a preceding comment 91 | --> __LINE__ 91 92 | #if 0 93 | /* multi-\ 94 | * line comment at flslvl=1 95 | */ 96 | #endif 97 | --> __LINE__ 97 98 | -------------------------------------------------------------------------------- /f77/f77/Makefile.in: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Makefile.in for the f77 frontend of pcc. 4 | # 5 | VPATH=@srcdir@ 6 | top_srcdir=@top_srcdir@ 7 | top_builddir=@top_builddir@ 8 | prefix = @prefix@ 9 | exec_prefix = @exec_prefix@ 10 | bindir = @bindir@ 11 | libdir = @libdir@ 12 | libexecdir = @libexecdir@ 13 | includedir = @includedir@ 14 | CC = @CC@ 15 | TARGOS = @targos@ 16 | TARGOSVER = @targosver@ 17 | TARGMACH = @targmach@ 18 | TARGET = @target@ 19 | VERSION = @PACKAGE_VERSION@ 20 | PCCLIBDIR = $(libdir)/pcc/$(TARGET)/$(VERSION)/lib 21 | PCCINCDIR = $(libdir)/pcc/$(TARGET)/$(VERSION)/include 22 | F77LIBDIR=-L$(prefix)/lib 23 | CFLAGS = @CFLAGS@ @ADD_CFLAGS@ 24 | CPPFLAGS = @CPPFLAGS@ @ADD_CPPFLAGS@ -DLANG_F77 \ 25 | -DLIBEXECDIR=\"$(libexecdir)\" -DINCLUDEDIR=\"$(includedir)\" \ 26 | -DPCCINCDIR=\"$(PCCINCDIR)/\" -DPCCLIBDIR=\"$(PCCLIBDIR)/\" \ 27 | -Dmach_$(TARGMACH) -Dos_$(TARGOS) \ 28 | -I$(top_srcdir)/cc/driver -I$(MIPDIR) -I$(COMMONDIR)\ 29 | -I$(FCOMDIR) -I$(top_builddir) -I$(top_srcdir)/os/$(TARGOS) -I$(MDIR) 30 | LIBS = @LIBS@ 31 | LDFLAGS = @LDFLAGS@ 32 | INSTALL = @INSTALL@ 33 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 34 | INSTALL_DATA = @INSTALL_DATA@ 35 | OBJS=f77.o strlist.o xalloc.o 36 | DEST=@BINPREFIX@f77 37 | 38 | MIPDIR=$(top_srcdir)/mip 39 | MDIR=$(top_srcdir)/arch/$(TARGMACH) 40 | FCOMDIR=$(top_srcdir)/f77/fcom 41 | COMMONDIR=$(top_srcdir)/common 42 | 43 | all: $(DEST) 44 | 45 | $(DEST): $(OBJS) 46 | $(CC) $(LDFLAGS) $(OBJS) -o $@ $(LIBS) 47 | 48 | strlist.o: $(top_srcdir)/cc/driver/strlist.c 49 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(top_srcdir)/cc/driver/strlist.c 50 | 51 | xalloc.o: $(top_srcdir)/cc/driver/xalloc.c 52 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(top_srcdir)/cc/driver/xalloc.c 53 | 54 | .c.o: 55 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< 56 | 57 | install: 58 | $(INSTALL_PROGRAM) $(DEST) $(bindir) 59 | 60 | clean: 61 | rm -f $(OBJS) $(DEST) 62 | 63 | distclean: clean 64 | rm -f Makefile 65 | -------------------------------------------------------------------------------- /os/win32/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Config file for visual studio build 3 | */ 4 | #define PREPROCESSOR "%PCCDIR%\\libexec\\cpp.exe" 5 | #define COMPILER "%PCCDIR%\\libexec\\ccom.exe" 6 | 7 | #define USE_YASM 8 | 9 | #ifdef USE_YASM 10 | #define ASSEMBLER "yasm.exe" 11 | #else 12 | #define ASSEMBLER "gas.exe" 13 | #endif 14 | 15 | #ifdef USE_MSLINKER 16 | #define LINKER "link.exe /nologo" 17 | #define MSLINKER 18 | #else 19 | #define LINKER "ld.exe" 20 | #endif 21 | 22 | 23 | #define PECOFFABI 24 | 25 | #define STDINC "%PCCDIR%\\include\\" 26 | #define LIBDIR "%PCCDIR%\\lib\\" 27 | #define INCLUDEDIR STDINC 28 | #define PCCLIBDIR "%PCCDIR%\\lib\\i386-win32\\1.1.0\\lib\\" 29 | #define PCCINCDIR "%PCCDIR%\\lib\\i386-win32\\1.1.0\\include\\" 30 | 31 | #if !defined(vsnprintf) 32 | #define vsnprintf _vsnprintf 33 | #endif 34 | /* windows defines (u)uintptr_t in stddef.h, not inttypes.h */ 35 | #include 36 | #if !defined(snprintf) 37 | #define snprintf _snprintf 38 | #endif 39 | 40 | #ifndef STDERR_FILENO 41 | #define STDERR_FILENO 2 42 | #endif 43 | 44 | #define inline __inline 45 | 46 | /* #define HAVE_INTTYPES_H 1 */ 47 | #define HAVE_MEMORY_H 1 48 | /* #define HAVE_MKSTEMP 1 */ 49 | 50 | #ifndef __MSC__ 51 | #define HAVE_STDINT_H 1 52 | #endif 53 | 54 | #define HAVE_STDLIB_H 1 55 | /* #define HAVE_STRINGS_H 1 */ 56 | #define HAVE_STRING_H 1 57 | /* #define HAVE_STRLCAT 1 */ 58 | /* #define HAVE_STRLCPY 1 */ 59 | #define HAVE_SYS_STAT_H 1 60 | #define HAVE_SYS_TYPES_H 1 61 | #define HAVE_SNPRINTF 1 62 | #define HAVE_VSNPRINTF 1 63 | /* #define HAVE_UNISTD_H 1 */ 64 | /* #define HOST_BIG_ENDIAN */ 65 | #define HOST_LITTLE_ENDIAN 66 | 67 | #define PACKAGE_NAME "pcc" 68 | #define PACKAGE_STRING "pcc 1.1.0" 69 | #define PACKAGE_TARNAME "pcc" 70 | #define PACKAGE_VERSION "1.1.0" 71 | #define PCC_MAJOR 1 72 | #define PCC_MINOR 1 73 | #define PCC_MINORMINOR 0 74 | #define STDC_HEADERS 1 75 | #define TARGET_LITTLE_ENDIAN 1 76 | #define VERSSTR "pcc 1.1.0 for win32, gmcgarry@pcc.ludd.ltu.se" 77 | #define WCHAR_SIZE 2 78 | #define WCHAR_TYPE USHORT 79 | #define YYTEXT_POINTER 1 80 | -------------------------------------------------------------------------------- /os/litebsd/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | * Various settings that controls how the C compiler works. 30 | */ 31 | 32 | /* common cpp predefines */ 33 | #define CPPADD { "-D__LiteBSD__", "-D__ELF__", "-D__unix__", \ 34 | NULL, } 35 | #define DYNLINKER { NULL } 36 | 37 | #ifdef LANG_F77 38 | #define F77LIBLIST { "-L/usr/local/lib", "-lF77", "-lI77", "-lm", "-lc", NULL }; 39 | #endif 40 | 41 | #define CPPMDADD { "-D__mips__", "-Dmips", "-D__mips=32", "-D__MIPSEL", \ 42 | "-D__MIPSEL__", "-DMIPSEL", "-D_MIPSEL", NULL, } 43 | 44 | #define DEFLIBS { "-lc", "-lgcc", NULL } 45 | 46 | /* We only have crt0.o */ 47 | #define CRTBEGIN 0 48 | #define CRTEND 0 49 | #define CRTI 0 50 | #define CRTN 0 51 | -------------------------------------------------------------------------------- /os/openbsd/f77config.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* 31 | * Various settings that controls how the f77 compiler works. 32 | */ 33 | 34 | #define PASS1NAME "/usr/lib/f77pass1" 35 | #define PASS2NAME "/lib/f1" 36 | #define PASS2OPT "/lib/c2" 37 | #define NOFLPASS2 "/lib/fc1" 38 | 39 | #define ASMNAME "/usr/bin/as" 40 | #define LDNAME "/usr/bin/ld" 41 | #define FOOTNAME "/usr/lib/crt0.o" 42 | #define PROFFOOT "/usr/lib/mcrt0.o" 43 | #define NOFLFOOT "/usr/lib/fcrt0.o" 44 | #define NOFLPROFFOOT "/usr/lib/fmcrt0.o" 45 | #define LIBLIST { "-lF77", "-lI77", "-lm", "-lc", "-l", NULL }; 46 | 47 | -------------------------------------------------------------------------------- /arch/sparc64/order.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2008 David Crawshaw 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include "pass2.h" 20 | 21 | /* is it legal to make an OREG or NAME entry which has an 22 | * offset of off, (from a register of r), if the 23 | * resulting thing had type t */ 24 | int 25 | notoff(TWORD t, int r, CONSZ off, char *cp) 26 | { 27 | return !SIMM13(off); 28 | } 29 | 30 | /* 31 | * Turn a UMUL-referenced node into OREG. 32 | */ 33 | void 34 | offstar(NODE *p, int shape) 35 | { 36 | if (x2debug) 37 | printf("offstar(%p)\n", p); 38 | 39 | if (p->n_op == PLUS || p->n_op == MINUS) { 40 | if (p->n_right->n_op == ICON && SIMM13(getlval(p->n_right))) { 41 | if (isreg(p->n_left) == 0) 42 | (void)geninsn(p->n_left, INAREG); 43 | /* Converted in ormake() */ 44 | return; 45 | } 46 | } 47 | (void)geninsn(p, INAREG); 48 | } 49 | 50 | void 51 | myormake(NODE *q) 52 | { 53 | } 54 | 55 | int 56 | shumul(NODE *p, int shape) 57 | { 58 | if (shape & SOREG) 59 | return SROREG; 60 | return SRNOPE; 61 | } 62 | 63 | int 64 | setbin(NODE *p) 65 | { 66 | return 0; 67 | } 68 | 69 | int 70 | setasg(NODE *p, int cookie) 71 | { 72 | return 0; 73 | } 74 | 75 | int 76 | setuni(NODE *p, int cookie) 77 | { 78 | return 0; 79 | } 80 | 81 | int 82 | setorder(NODE *p) 83 | { 84 | return 0; 85 | } 86 | 87 | int * 88 | livecall(NODE *p) 89 | { 90 | static int ret[] = { O0, O1, O2, O3, O4, O5, O6, O7, -1 }; 91 | return ret; 92 | } 93 | 94 | int 95 | acceptable(struct optab *op) 96 | { 97 | return 1; 98 | } 99 | -------------------------------------------------------------------------------- /os/midnightbsd/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /*- 3 | * Copyright (c) 2007, 2008 4 | * Thorsten Glaser 5 | * 6 | * Provided that these terms and disclaimer and all copyright notices 7 | * are retained or reproduced in an accompanying document, permission 8 | * is granted to deal in this work without restriction, including un- 9 | * limited rights to use, publicly perform, distribute, sell, modify, 10 | * merge, give away, or sublicence. 11 | * 12 | * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 13 | * the utmost extent permitted by applicable law, neither express nor 14 | * implied; without malicious intent or gross negligence. In no event 15 | * may a licensor, author or contributor be held liable for indirect, 16 | * direct, other damage, loss, or other issues arising in any way out 17 | * of dealing in the work, even if advised of the possibility of such 18 | * damage or existence of a defect, except proven that it results out 19 | * of said person's immediate fault when using the work as intended. 20 | */ 21 | 22 | /** 23 | * Configuration for pcc on a MidnightBSD (amd64, i386 or sparc64) target 24 | */ 25 | 26 | /* === mi part === */ 27 | 28 | /* cpp MI defines */ 29 | #define CPPADD { \ 30 | "-D__MidnightBSD__", \ 31 | "-D__FreeBSD__", \ 32 | "-D__unix__", \ 33 | "-D__unix", \ 34 | "-Dunix", \ 35 | "-D__ELF__", \ 36 | "-D_LONGLONG", \ 37 | NULL \ 38 | } 39 | 40 | /* for dynamically linked binaries */ 41 | #define DYNLINKLIB "/libexec/ld-elf.so.1" 42 | 43 | /* C run-time startup */ 44 | #define CRT0 "crt1.o" 45 | #define GCRT0 "gcrt1.o" 46 | 47 | #define CRTEND_T "crtend.o" 48 | 49 | /* === md part === */ 50 | 51 | #if defined(mach_i386) 52 | #define CPPMDADD { \ 53 | "-D__i386__", \ 54 | "-D__i386", \ 55 | "-Di386", \ 56 | NULL, \ 57 | } 58 | #elif defined(mach_sparc64) 59 | #define CPPMDADD { \ 60 | "-D__sparc64__", \ 61 | "-D__sparc_v9__", \ 62 | "-D__sparcv9", \ 63 | "-D__sparc__", \ 64 | "-D__sparc", \ 65 | "-Dsparc", \ 66 | "-D__arch64__", \ 67 | "-D__LP64__", \ 68 | "-D_LP64", \ 69 | NULL, \ 70 | } 71 | #elif defined(mach_amd64) 72 | #error pcc does not support amd64 yet 73 | #else 74 | #error this architecture is not supported by MidnightBSD 75 | #endif 76 | -------------------------------------------------------------------------------- /os/sysv4/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Adam Hoka. 5 | * Modified from sunos files slightly by Gregor Richards. 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. The name of the author may not be used to endorse or promote products 17 | * derived from this software without specific prior written permission 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * Various settings that controls how the C compiler works. 33 | */ 34 | 35 | /* common cpp predefines */ 36 | #define CPPADD { "-Dunix", "-D__SVR4", "-D__unix", "-D__svr4__", "-D__ELF__", NULL } 37 | 38 | /* host-dependent */ 39 | #define CRT0 "crt1.o" 40 | #define GCRT0 "gcrt1.o" 41 | 42 | #ifdef LANG_F77 43 | #define F77LIBLIST { "-L/usr/local/lib", "-lF77", "-lI77", "-lm", "-lc", NULL }; 44 | #endif 45 | 46 | #define DYNLINKARG "--dynamic-linker" 47 | #define DYNLINKLIB "/usr/lib/ld.so.1" 48 | 49 | #if defined(mach_i386) 50 | #define CPPMDADD { "-D__i386__", "-D__i386", NULL, } 51 | #else 52 | #error defines for arch missing 53 | #endif 54 | 55 | #define STABS 56 | -------------------------------------------------------------------------------- /arch/i86/TODO: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8086/80186 4 | ---------- 5 | Add CPU options 6 | Make push immediate, imul, shift immediate and enter/leave 186 specific 7 | Optimise >> 8 and friends as register moves (note that the core compiler 8 | code also goes off and turns * 256 into << 8) 9 | 10 | Unstarted 11 | --------- 12 | Float 13 | 14 | Struct/Union testing 15 | 16 | Maths optimisation. Div/mul on 8086 are *slow* so generate stack/double and 17 | other optimised forms 18 | 19 | Long helper methods (out of line 32bit mul etc) 20 | 21 | Make long long a class E with 64bit types and four virtual registers 22 | rewritten as memory. 23 | 24 | Other call formats 25 | 26 | Optimisation 27 | ------------ 28 | Avoid sp,bp set up if we can on entry/exit 29 | 30 | Delayed sp adjustments 31 | 32 | Don't adjust sp then reload it from bp! 33 | 34 | Register constant tracking (especially important as we often know where a 35 | zero word or byte is and we can use it for push immediate #0) 36 | 37 | Spotting two halves of a 32bit value being the same and merging 38 | 39 | Allow moves between half registers and their full shadow (al->ax) for char 40 | to short etc. How to balance compilers tendancy to allocate AL, AH, etc 41 | which is good for register freedom and bad for chars ? 42 | 43 | Better uchar handling - if we allocated xL before xH somehow in all cases 44 | then we would be able to do xL -> xX efficiently. 45 | 46 | We get very poor code because the compiler doesn't understand that type 47 | converting al does not destroy al, only ah and the al/ax relationship. In 48 | particular with char args it loves to write crap like 49 | 50 | 51 | mov bl, 1 52 | ... 53 | mov al, bl 54 | cbw 55 | push ax 56 | mov al, bl 57 | cbw 58 | inc ax 59 | push ax 60 | 61 | not 62 | mov al, 1 63 | cbw 64 | push ax 65 | inc al 66 | cbw 67 | push ax 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Questions 76 | --------- 77 | An assembler programmer would not 78 | 79 | mov al, #14 80 | cbw 81 | 82 | but would 83 | 84 | mov ax, #0014 85 | 86 | not obvious how we do that optimisation with pcc in all cases but its important 87 | 88 | Can we optimise compare with zero cases ? 89 | 90 | How do we make use of rep and loopXX, these are rather useful on 8086 but 91 | need indexes to tend to use the right register 92 | 93 | Should there be a CPU type/feature match in table.c ? -------------------------------------------------------------------------------- /cc/cpp/Makefile.in: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Makefile.in for cpp 4 | # 5 | VPATH=@srcdir@ 6 | srcdir=@srcdir@ 7 | top_srcdir=@top_srcdir@ 8 | builddir=@builddir@ 9 | top_builddir=@top_builddir@ 10 | prefix = @prefix@ 11 | exec_prefix = @exec_prefix@ 12 | bindir = @bindir@ 13 | libexecdir = @libexecdir@ 14 | datarootdir = @datarootdir@ 15 | mandir = @mandir@ 16 | CC = @CC@ 17 | EXEEXT = @EXEEXT@ 18 | CFLAGS = @CFLAGS@ @ADD_CFLAGS@ 19 | CPPFLAGS = @CPPFLAGS@ @ADD_CPPFLAGS@ \ 20 | -I$(srcdir) -I$(top_builddir) -I$(builddir) -I$(MIPDIR) -I$(MDIR) \ 21 | -I$(COMMONDIR) -DNVMPGS=4 22 | LIBS = @LIBS@ 23 | LDFLAGS = @LDFLAGS@ 24 | YACC = @YACC@ 25 | YFLAGS = @YFLAGS@ 26 | INSTALL = @INSTALL@ 27 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 28 | INSTALL_DATA = @INSTALL_DATA@ 29 | TARGMACH = @targmach@ 30 | 31 | MIPDIR=$(top_srcdir)/mip 32 | MDIR=$(top_srcdir)/arch/$(TARGMACH) 33 | COMMONDIR=$(top_srcdir)/common 34 | 35 | DEST=@BINPREFIX@cpp$(EXEEXT) 36 | MANPAGE=@BINPREFIX@cpp 37 | 38 | all: $(DEST) 39 | 40 | OBJS= compat.o cpp.o cpc.o token.o 41 | HDRS= cpp.h 42 | 43 | $(OBJS): $(HDRS) 44 | 45 | compat.o: $(COMMONDIR)/compat.c 46 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(COMMONDIR)/compat.c 47 | 48 | cpp.o: $(srcdir)/cpp.c 49 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(srcdir)/cpp.c 50 | 51 | cpc.o: $(srcdir)/cpc.c 52 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(srcdir)/cpc.c 53 | 54 | token.o: $(srcdir)/token.c 55 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(srcdir)/token.c 56 | 57 | $(DEST): $(OBJS) 58 | $(CC) $(LDFLAGS) $(OBJS) -o $@ $(LIBS) 59 | 60 | test: $(DEST) 61 | @for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ; do \ 62 | echo -n "test$${n} " ; \ 63 | ./$(DEST) < tests/test$${n} > tests/run$${n} && \ 64 | cmp tests/run$${n} tests/res$${n} && echo ; \ 65 | if test -f tests/res$${n}C ; then \ 66 | echo -n "test$${n}C " ; \ 67 | ./$(DEST) -C < tests/test$${n} > tests/run$${n}C && \ 68 | cmp tests/run$${n}C tests/res$${n}C && echo ; \ 69 | fi ; \ 70 | done 71 | 72 | install: 73 | test -z "$(DESTDIR)$(libexecdir)" || mkdir -p "$(DESTDIR)$(libexecdir)" 74 | $(INSTALL_PROGRAM) $(DEST) $(DESTDIR)$(libexecdir) 75 | test -z "$(DESTDIR)$(mandir)/man1" || mkdir -p "$(DESTDIR)$(mandir)/man1" 76 | $(INSTALL_DATA) $(srcdir)/cpp.1 $(DESTDIR)$(mandir)/man1/$(MANPAGE).1 77 | 78 | clean: 79 | rm -f $(OBJS) $(DEST) tests/run* 80 | 81 | distclean: clean 82 | rm -f Makefile 83 | -------------------------------------------------------------------------------- /os/android/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | * Various settings that controls how the C compiler works. 30 | */ 31 | 32 | /* common cpp predefines */ 33 | #define CPPADD { "-D__ANDROID__", "-D__linux__", "-D__ELF__", NULL, } 34 | 35 | #define CRT0 "crt1.o" 36 | #define GCRT0 "gcrt1.o" 37 | #define DYNLINKLIB "/system/bin/linker" 38 | 39 | #define STARTLABEL "_start" 40 | 41 | #if defined(mach_i386) 42 | #define CPPMDADD { "-D__i386__", NULL, } 43 | #elif defined(mach_amd64) 44 | #define CPPMDADD { "-D__x86_64__", "-D__x86_64", "-D__amd64__", \ 45 | "-D__amd64", "-D__LP64__", "-D_LP64", NULL, } 46 | #define DEFLIBDIRS { "/usr/lib64/", 0 } 47 | #elif defined(mach_mips) 48 | #define CPPMDADD { "-D__mips__", NULL, } 49 | #elif defined(mach_arm) 50 | #define CPPMDADD { "-D__arm__", NULL, } 51 | #else 52 | #error defines for arch missing 53 | #endif 54 | 55 | 56 | #define PCC_EARLY_ARG_CHECK { \ 57 | if (match(argp, "-no-canonical-prefixes")) { \ 58 | continue; \ 59 | } \ 60 | } 61 | 62 | -------------------------------------------------------------------------------- /os/none/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* 31 | * Various settings that controls how the C compiler works. 32 | */ 33 | 34 | /* 35 | * This file is for targets where there is no OS 36 | */ 37 | 38 | /* common cpp predefines */ 39 | #define CPPADD { NULL, } 40 | #define CRT0FILE "" 41 | #define STARTFILES { NULL } 42 | #define ENDFILES { NULL } 43 | 44 | #if defined(mach_arm) 45 | #define CPPMDADD { "-D__arm__", NULL, } 46 | #elif defined(mach_i86) 47 | #define CPPMDADD { "-D__i86__", NULL, } 48 | #elif defined(mach_m16c) 49 | #define CPPMDADD { "-D__m16c__", NULL, } 50 | #elif defined(mach_m68k) 51 | #define CPPMDADD { "-D__m68k__", NULL, } 52 | #elif defined(mach_nova) 53 | #define CPPMDADD { "-D__nova__", NULL, } 54 | #elif defined(mach_pdp7) 55 | #define CPPMDADD { "-D__pdp7__", "-Dpdp7", NULL, } 56 | #else 57 | #error defines for arch missing 58 | #endif 59 | -------------------------------------------------------------------------------- /cc/driver/xalloc.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /*- 4 | * Copyright (c) 2011 Joerg Sonnenberger . 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "xalloc.h" 37 | 38 | static void 39 | error(const char *str) 40 | { 41 | fprintf(stderr, "%s\n", str); 42 | exit(1); 43 | } 44 | 45 | void * 46 | xcalloc(size_t elem, size_t len) 47 | { 48 | void *ptr; 49 | 50 | if ((ptr = calloc(elem, len)) == NULL) 51 | error("calloc failed"); 52 | return ptr; 53 | } 54 | 55 | void * 56 | xmalloc(size_t len) 57 | { 58 | void *ptr; 59 | 60 | if ((ptr = malloc(len)) == NULL) 61 | error("malloc failed"); 62 | return ptr; 63 | } 64 | 65 | void * 66 | xrealloc(void *buf, size_t len) 67 | { 68 | void *ptr; 69 | 70 | if ((ptr = realloc(buf, len)) == NULL) 71 | error("realloc failed"); 72 | return ptr; 73 | } 74 | 75 | char * 76 | xstrdup(const char *str) 77 | { 78 | char *buf; 79 | 80 | if ((buf = strdup(str)) == NULL) 81 | error("strdup failed"); 82 | return buf; 83 | } 84 | -------------------------------------------------------------------------------- /os/inc/amd64.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2012 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #define CPPMDADD { "-D__x86_64__", "-D__x86_64", "-D__amd64__", \ 29 | "-D__amd64", "-D__LP64__", "-D_LP64", NULL, } 30 | 31 | /* fixup small m options */ 32 | #ifndef AMD64_64_EMUL 33 | #define AMD64_64_EMUL "elf_x86_64" 34 | #endif 35 | #ifndef AMD64_32_EMUL 36 | #define AMD64_32_EMUL "elf_i386" 37 | #endif 38 | #define PCC_EARLY_ARG_CHECK { \ 39 | if (match(argp, "-m32")) { \ 40 | argp = "-m" AMD64_32_EMUL; \ 41 | strlist_append(&middle_linker_flags, argp); \ 42 | continue; \ 43 | } else if (match(argp, "-m64")) { \ 44 | argp = "-m" AMD64_64_EMUL; \ 45 | strlist_append(&middle_linker_flags, argp); \ 46 | continue; \ 47 | } else if (strncmp(argp, "-mcmodel", 9) == 0) { \ 48 | strlist_append(&compiler_flags, argp); \ 49 | continue; \ 50 | } else if (match(argp, "-melf_i386")) { \ 51 | pass0 = LIBEXECDIR "/ccom_i386"; \ 52 | amd64_i386 = 1; \ 53 | continue; \ 54 | } \ 55 | } 56 | 57 | #define TARGET_GLOBALS int amd64_i386; 58 | 59 | #define TARGET_ASFLAGS { &amd64_i386, 1, "--32" }, 60 | -------------------------------------------------------------------------------- /cc/driver/driver.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /*- 4 | * Copyright (c) 2011 Joerg Sonnenberger . 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef DRIVER_H 33 | #define DRIVER_H 34 | 35 | #include "strlist.h" 36 | 37 | extern const char *isysroot; 38 | extern const char *sysroot; 39 | extern const char *preprocessor; 40 | extern const char *compiler; 41 | extern const char *assembler; 42 | extern const char *linker; 43 | 44 | extern struct strlist crtdirs; 45 | extern struct strlist sysincdirs; 46 | extern struct strlist libdirs; 47 | extern struct strlist progdirs; 48 | extern struct strlist preprocessor_flags; 49 | extern struct strlist compiler_flags; 50 | extern struct strlist assembler_flags; 51 | extern struct strlist early_linker_flags; 52 | extern struct strlist middle_linker_flags; 53 | extern struct strlist late_linker_flags; 54 | extern struct strlist stdlib_flags; 55 | extern struct strlist early_program_csu_files; 56 | extern struct strlist late_program_csu_files; 57 | extern struct strlist early_dso_csu_files; 58 | extern struct strlist late_dso_csu_files; 59 | 60 | void error(const char *fmt, ...); 61 | 62 | void init_platform_specific(const char *, const char *); 63 | 64 | #endif /* DRIVER_H */ 65 | -------------------------------------------------------------------------------- /os/nextstep/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* 31 | * Various settings that controls how the C compiler works. 32 | */ 33 | 34 | /* common cpp predefines */ 35 | #define CPPADD { \ 36 | "-D__NeXT__", \ 37 | "-I" LIBDIR "ansi", \ 38 | "-I" LIBDIR "bsd", \ 39 | NULL \ 40 | } 41 | 42 | #define CRTBEGIN 0 43 | #define CRTBEGIN_S 0 44 | #define CRTBEGIN_T 0 45 | #define CRTEND 0 46 | #define CRTEND_S 0 47 | #define CRTEND_T 0 48 | #define CRTI 0 49 | #define CRTN 0 50 | 51 | #define CRT0 "crt1.o" 52 | #define GCRT0 "gcrt1.o" 53 | 54 | #define LIBCLIBS { "-lc", "-lpcc", NULL } 55 | #define LIBCLIBS_PROFILE { "-lc", "-lpcc", NULL } 56 | 57 | #define STARTLABEL "start" 58 | 59 | /* 60 | ld -arch ppc -weak_reference_mismatches non-weak -o a.out -lcrt1.o -lcrt2.o -L/usr/lib/gcc/powerpc-apple-darwin8/4.0.1 hello_ppc.o -lgcc -lSystemStubs -lSystem 61 | */ 62 | 63 | #if defined(mach_i386) 64 | #define CPPMDADD { "-D__i386__", "-D__LITTLE_ENDIAN__", NULL } 65 | #elif defined(mach_powerpc) 66 | #define CPPMDADD { "-D__ppc__", "-D__BIG_ENDIAN__", NULL } 67 | #else 68 | #error defines for arch missing 69 | #endif 70 | -------------------------------------------------------------------------------- /arch/powerpc/README: -------------------------------------------------------------------------------- 1 | macdefs.h ; machine-dependent definitions 2 | code.c ; machine-dependent code for prologs, switches (pass 1) 3 | local.c ; machine-dependent code for prologs, switches (pass 1) 4 | local2.c ; misc routines and tables of register names (pass 2) 5 | order.c ; machine-dependent code-generation strategy (pass 2) 6 | table.c ; code templates (pass 2) 7 | 8 | On OS X, binaries are not ELF and all binaries are compiled PIC. To use pcc 9 | on OS X while linking against the system libraries, use the -k option. 10 | 11 | Current issues: 12 | 13 | - no floating point (need mickey's patches to support >64 registers) 14 | - mod/div on longlong not supported 15 | - the stack frame is always 200 bytes - need to calculate size and patch 16 | OREGs to temporaries and arguments [see discussion below] 17 | - function arguments are always saved to the stack [need to change MI code] 18 | - permanent registers >R13 are not saved [need to change MI code] 19 | - structure arguments don't work 20 | - return of structure doesn't work 21 | - function pointers don't work for PIC 22 | - constant structure assignment doesn't work properly for PIC 23 | - no built-in vararg support [shouldn't be too hard to add] 24 | 25 | The way most modern CPUs create the stack is to allocate the frame 26 | to contain room for the temporaries, to save the permanent registers 27 | and to store the arguments to functions invoked from within the function. 28 | To achieve this, all the information must be known when the prologue 29 | is generated. Currently we only know the size of the temporaries - 30 | we don't know the size of the argument space for each function that 31 | gets invoked from this function. Even if we did know this information, 32 | we create ops to save the register arguments (R3-R10), early in pass1 33 | and don't know the position of the stack pointer, and the size of the 34 | argument space required to "step over". 35 | 36 | One solution is to have two pointers to the stack. One for the top 37 | of the stack and the other pointing just below the temporaries but above 38 | the argument space. Then our function arguments and the permanent registers can 39 | be saved fixed-relative to this register. If we don't know the size of 40 | argument space, we cannot "dynamically" alter the stack (like we do with mips), 41 | since the powerpc ABI specifies that the "lowest" address 42 | in the stack frame is the saved stack pointer (pointing to the previous 43 | stack frame). While this is a nice feature for tracking back through the 44 | stack frames (which mips has always had problems with), it makes it 45 | next-to-impossible to increase the strack frame dynamically. 46 | 47 | I guess the best approach is to determine the size of the argument stack 48 | and have a second frame pointer. 49 | -------------------------------------------------------------------------------- /os/freebsd/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /*- 4 | * Copyright (c) 2007 David O'Brien 5 | * Copyright (c) 2007 Ed Schouten 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #define CPPADD { "-D__FreeBSD__=" MKS(TARGOSVER), "-D__ELF__", \ 31 | "-D__unix__=1", "-D__unix=1", NULL, } 32 | 33 | /* host-dependent */ 34 | #define CRT0 "crt1.o" 35 | #define GCRT0 "gcrt1.o" 36 | #define DYNLINKLIB "/libexec/ld-elf.so.1" 37 | #define STARTLABEL "_start" 38 | 39 | #if defined(mach_i386) 40 | #define CPPMDADD { "-D__i386__", "-D__i386", NULL, } 41 | #elif defined(mach_amd64) 42 | #define AMD64_32_EMUL "elf_i386_fbsd" 43 | #define AMD64_64_EMUL "elf_x86_64_fbsd" 44 | #include "../inc/amd64.h" 45 | #elif defined(mach_sparc64) 46 | #define CPPMDADD \ 47 | { "-D__sparc64__", "-D__sparc_v9__", "-D__sparc__", "-D__sparc",\ 48 | "-D__LP64__=1", "-D_LP64=1", NULL, } 49 | #else 50 | #error defines for arch missing 51 | #endif 52 | 53 | /* FreeBSD do not have any assembler anymore, so use clang for that */ 54 | #if __FreeBSD__ >= 12 55 | /* Only if the user didn't explictly select an assembler with --with-assembler 56 | One can install the binutils package on FreeBSD, then choose to use GNU as. 57 | */ 58 | #ifndef ASSEMBLER 59 | #define PCC_EARLY_AS_ARGS strlist_append(&args, "-xassembler"); strlist_append(&args, "-c"); 60 | #define ASSEMBLER "clang" 61 | #endif 62 | #endif 63 | 64 | #ifdef LANG_F77 65 | #define F77LIBLIST { "-lF77", "-lI77", "-lm", "-lc", NULL }; 66 | #endif 67 | -------------------------------------------------------------------------------- /cc/cc/Makefile.in: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | # 3 | # Makefile.in for the cc part of pcc. 4 | # 5 | VPATH=@srcdir@ 6 | srcdir=@srcdir@ 7 | top_srcdir=@top_srcdir@ 8 | top_builddir=@top_builddir@ 9 | prefix = @prefix@ 10 | exec_prefix = @exec_prefix@ 11 | bindir = @bindir@ 12 | libdir = @libdir@ 13 | libexecdir = @libexecdir@ 14 | includedir = @includedir@ 15 | datarootdir = @datarootdir@ 16 | mandir = @mandir@ 17 | CC = @CC@ 18 | EXEEXT = @EXEEXT@ 19 | BINPREFIX = @BINPREFIX@ 20 | TARGOS = @targos@ 21 | TARGOSVER = @targosver@ 22 | TARGMACH = @targmach@ 23 | TARGMACHDIR = @targmachdir@ 24 | TARGET = @target@ 25 | VERSION = @PACKAGE_VERSION@ 26 | PCCLIBDIR = $(libdir)/pcc/$(TARGET)/$(VERSION)/lib 27 | PCCINCDIR = $(libdir)/pcc/$(TARGET)/$(VERSION)/include 28 | CFLAGS = @CFLAGS@ @ADD_CFLAGS@ 29 | CPPFLAGS = @CPPFLAGS@ -DLIBEXECDIR=\"$(libexecdir)/\" \ 30 | @ADD_CPPFLAGS@ -DINCLUDEDIR=\"$(includedir)/\" \ 31 | -DPCCINCDIR=\"$(PCCINCDIR)/\" -DPCCLIBDIR=\"$(PCCLIBDIR)/\" \ 32 | -Dos_$(TARGOS) -Dmach_$(TARGMACH) -DTARGOSVER=$(TARGOSVER) \ 33 | -DCXXPROGNAME=\"$(BINPREFIX)p++$(EXEEXT)\" \ 34 | -DCPPROGNAME=\"$(BINPREFIX)pcpp$(EXEEXT)\" \ 35 | -DCC0=\"$(BINPREFIX)cc0$(EXEEXT)\" -DCC1=\"$(BINPREFIX)cc1$(EXEEXT)\" \ 36 | -I$(top_srcdir)/cc/driver -I$(top_builddir) \ 37 | -I$(top_srcdir)/os/$(TARGOS) -I$(MIPDIR) -I$(MDIR) -I$(COMMONDIR) 38 | LIBS = @LIBS@ 39 | LDFLAGS = @LDFLAGS@ 40 | INSTALL = @INSTALL@ 41 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 42 | INSTALL_DATA = @INSTALL_DATA@ 43 | 44 | MIPDIR=$(top_srcdir)/mip 45 | MDIR=$(top_srcdir)/arch/$(TARGMACHDIR) 46 | COMMONDIR=$(top_srcdir)/common 47 | 48 | DEST=$(BINPREFIX)cc$(EXEEXT) 49 | DRIVERS=pcc pcpp p++ 50 | 51 | all: $(DEST) 52 | 53 | OBJS= cc.o compat.o strlist.o xalloc.o 54 | 55 | cc.o: $(srcdir)/cc.c 56 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(srcdir)/cc.c 57 | 58 | compat.o: $(COMMONDIR)/compat.c 59 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(COMMONDIR)/compat.c 60 | 61 | strlist.o: $(top_srcdir)/cc/driver/strlist.c 62 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(top_srcdir)/cc/driver/strlist.c 63 | 64 | xalloc.o: $(top_srcdir)/cc/driver/xalloc.c 65 | $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(top_srcdir)/cc/driver/xalloc.c 66 | 67 | $(DEST): $(OBJS) 68 | $(CC) $(LDFLAGS) $(OBJS) -o $@ $(LIBS) 69 | 70 | install: 71 | test -z "$(DESTDIR)$(bindir)" || mkdir -p "$(DESTDIR)$(bindir)" 72 | test -z "$(DESTDIR)$(mandir)/man1" || mkdir -p "$(DESTDIR)$(mandir)/man1" 73 | @for driver in $(DRIVERS); do \ 74 | $(INSTALL_PROGRAM) $(DEST) $(DESTDIR)$(bindir)/$(BINPREFIX)$$driver$(EXEEXT); \ 75 | $(INSTALL_DATA) $(srcdir)/cc.1 $(DESTDIR)$(mandir)/man1/$(BINPREFIX)$$driver.1; \ 76 | done 77 | test -z "$(DESTDIR)$(PCCINCDIR)" || mkdir -p "$(DESTDIR)$(PCCINCDIR)" 78 | test -z "$(DESTDIR)$(PCCLIBDIR)" || mkdir -p "$(DESTDIR)$(PCCLIBDIR)" 79 | 80 | clean: 81 | rm -f $(OBJS) $(DEST) 82 | 83 | distclean: clean 84 | rm -f Makefile 85 | -------------------------------------------------------------------------------- /f77/fcom/gram.exec: -------------------------------------------------------------------------------- 1 | exec: iffable 2 | | SDO end_spec label opt_comma dospec 3 | { 4 | if($3->labdefined) 5 | execerr("no backward DO loops"); 6 | $3->blklevel = blklevel+1; 7 | exdo($3->labelno, $5); 8 | } 9 | | logif iffable 10 | { exendif(); thiswasbranch = NO; } 11 | | logif STHEN 12 | | SELSEIF end_spec SLPAR expr SRPAR STHEN 13 | { exelif($4); lastwasbranch = NO; } 14 | | SELSE end_spec 15 | { exelse(); lastwasbranch = NO; } 16 | | SENDIF end_spec 17 | { exendif(); lastwasbranch = NO; } 18 | ; 19 | 20 | logif: SLOGIF end_spec SLPAR expr SRPAR 21 | { exif($4); } 22 | ; 23 | 24 | dospec: name SEQUALS exprlist 25 | { $$ = mkchain($1, $3); } 26 | ; 27 | 28 | iffable: let lhs SEQUALS expr 29 | { exequals($2, $4); } 30 | | SASSIGN end_spec labelval STO name 31 | { exassign($5, $3); } 32 | | SCONTINUE end_spec 33 | | goto 34 | | io 35 | { inioctl = NO; } 36 | | SARITHIF end_spec SLPAR expr SRPAR label SCOMMA label SCOMMA label 37 | { exarif($4, $6, $8, $10); thiswasbranch = YES; } 38 | | call 39 | { excall($1, 0, 0, labarray); } 40 | | call SLPAR SRPAR 41 | { excall($1, 0, 0, labarray); } 42 | | call SLPAR callarglist SRPAR 43 | { excall($1, mklist($3), nstars, labarray); } 44 | | SRETURN end_spec opt_expr 45 | { exreturn($3); thiswasbranch = YES; } 46 | | stop end_spec opt_expr 47 | { exstop($1, $3); thiswasbranch = $1; } 48 | ; 49 | 50 | let: SLET 51 | { if(parstate == OUTSIDE) 52 | { 53 | newproc(); 54 | startproc(0, CLMAIN); 55 | } 56 | } 57 | ; 58 | 59 | goto: SGOTO end_spec label 60 | { exgoto($3); thiswasbranch = YES; } 61 | | SASGOTO end_spec name 62 | { exasgoto($3); thiswasbranch = YES; } 63 | | SASGOTO end_spec name opt_comma SLPAR labellist SRPAR 64 | { exasgoto($3); thiswasbranch = YES; } 65 | | SCOMPGOTO end_spec SLPAR labellist SRPAR opt_comma expr 66 | { putcmgo(fixtype($7), nstars, labarray); } 67 | ; 68 | 69 | opt_comma: 70 | | SCOMMA 71 | ; 72 | 73 | call: SCALL end_spec name 74 | { nstars = 0; $$ = $3; } 75 | ; 76 | 77 | callarglist: callarg 78 | { $$ = ($1 ? mkchain($1,0) : 0); } 79 | | callarglist SCOMMA callarg 80 | { if($3) { 81 | if($1) $$ = hookup($1, mkchain($3,0)); 82 | else $$ = mkchain($3,0); 83 | } 84 | } 85 | ; 86 | 87 | callarg: expr 88 | | SSTAR label 89 | { labarray[nstars++] = $2; $$ = 0; } 90 | ; 91 | 92 | stop: SPAUSE 93 | { $$ = 0; } 94 | | SSTOP 95 | { $$ = 1; } 96 | ; 97 | 98 | exprlist: expr 99 | { $$ = mkchain($1, 0); } 100 | | exprlist SCOMMA expr 101 | { $$ = hookup($1, mkchain($3,0) ); } 102 | ; 103 | 104 | end_spec: 105 | { if(parstate == OUTSIDE) 106 | { 107 | newproc(); 108 | startproc(0, CLMAIN); 109 | } 110 | if(parstate < INDATA) enddcl(); 111 | } 112 | ; 113 | -------------------------------------------------------------------------------- /os/bsd/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | * Various settings that controls how the C compiler works. 30 | */ 31 | 32 | /* common cpp predefines */ 33 | #if defined(mach_vax) 34 | #define CPPADD { "-D__BSD43__", "-DBSD=43", "-DBSD4_3=1", NULL } 35 | #else 36 | #define CPPADD { "-D__BSD2_11__", "-DBSD2_11", NULL } 37 | #endif 38 | 39 | /* host-dependent */ 40 | #define CRT0 "/lib/crt0.o" 41 | #define CRTBEGIN 0 42 | #define CRTEND 0 43 | #define CRTI 0 44 | #define CRTN 0 45 | 46 | #ifdef LANG_F77 47 | #define F77LIBLIST { "-L/usr/lib", "-lF77", "-lI77", "-lm", "-lc", NULL }; 48 | #endif 49 | 50 | #if defined(mach_pdp11) 51 | #define CPPMDADD { "-D__pdp11__", "-Dpdp11", NULL, } 52 | #define DEFLIBS { "-lc", 0 } 53 | #elif defined(mach_nova) 54 | #define CPPMDADD { "-D__nova__", "-Dnova", NULL, } 55 | #elif defined(mach_vax) 56 | #define CPPMDADD { "-D__vax__", "-Dvax", NULL, } 57 | #else 58 | #error defines for arch missing 59 | #endif 60 | 61 | #if defined(mach_pdp11) 62 | #define PCC_EARLY_AS_ARGS \ 63 | strlist_append(&args, "-V"); \ 64 | strlist_append(&args, "-u"); 65 | 66 | #define NO_AS_V 67 | #define NO_LD_D 68 | 69 | #if !defined(mach_vax) 70 | #define PCC_SETUP_LD_ARGS \ 71 | strlist_append(&early_linker_flags, "-X"); 72 | #endif 73 | #define STARTLABEL "start" 74 | #endif /* mach_pdp11 */ 75 | 76 | #if defined(mach_nova) 77 | #define HAVE_CC2 /* compile cc2 as well */ 78 | #define NEED_CC2 /* always use cc2 */ 79 | #endif /* if mach_nova */ 80 | -------------------------------------------------------------------------------- /os/dragonfly/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* 31 | * Various settings that controls how the C compiler works. 32 | */ 33 | 34 | #include 35 | 36 | /* common cpp predefines */ 37 | #define CPPADD { "-D__DragonFly__", "-D__ELF__", NULL, } 38 | 39 | #if __DragonFly_version < 200202 40 | #define CRT0FILE "/usr/lib/gcc34/crt1.o" 41 | #define CRT0FILE_PROFILE "/usr/lib/gcc34/gcrt1.o" 42 | #define STARTFILES { "/usr/lib/gcc34/crti.o", "/usr/lib/gcc34/crtbegin.o", NULL } 43 | #define LIBCLIBS { "-lc", "-L/usr/lib/gcc34", "-lgcc", NULL } 44 | #define ENDFILES { "/usr/lib/gcc34/crtend.o", "/usr/lib/gcc34/crtn.o", NULL } 45 | #else 46 | #define CRT0FILE "/usr/lib/crt1.o" 47 | #define CRT0FILE_PROFILE "/usr/lib/gcrt1.o" 48 | #define STARTFILES { "/usr/lib/crti.o", "/usr/lib/gcc41/crtbegin.o", NULL } 49 | #define LIBCLIBS { "-lc", "-L/usr/lib/gcc41", "-lgcc", NULL } 50 | #define ENDFILES { "/usr/lib/gcc41/crtend.o", "/usr/lib/crtn.o", NULL } 51 | #endif 52 | 53 | #define DYNLINKLIB "/usr/libexec/ld-elf.so.2" 54 | #define STARTLABEL "_start" 55 | 56 | #if defined(mach_i386) 57 | #define CPPMDADD { "-D__i386__", NULL, } 58 | #elif defined(mach_amd64) 59 | #define CPPMDADD \ 60 | { "-D__x86_64__", "-D__x86_64", "-D__amd64__", "-D__amd64", \ 61 | "-D__LP64__=1", "-D_LP64=1", NULL, } 62 | #else 63 | #error defines for arch missing 64 | #endif 65 | -------------------------------------------------------------------------------- /cc/driver/strlist.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /*- 4 | * Copyright (c) 2011 Joerg Sonnenberger . 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in 15 | * the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 28 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef STRLIST_H 33 | #define STRLIST_H 34 | 35 | #include 36 | #include 37 | 38 | struct string { 39 | struct string *next; 40 | char *value; 41 | }; 42 | 43 | struct strlist { 44 | struct string *first; 45 | struct string *last; 46 | }; 47 | 48 | void strlist_init(struct strlist *); 49 | void strlist_free(struct strlist *); 50 | void strlist_make_array(const struct strlist *, char ***, size_t *); 51 | void strlist_print(const struct strlist *, FILE *, int, const char *); 52 | 53 | void strlist_prepend(struct strlist *, const char *); 54 | void strlist_prepend_nocopy(struct strlist *, char *); 55 | void strlist_prepend_list(struct strlist *, const struct strlist *); 56 | void strlist_append(struct strlist *, const char *); 57 | void strlist_append_nocopy(struct strlist *, char *); 58 | void strlist_append_list(struct strlist *, const struct strlist *); 59 | void strlist_append_array(struct strlist *, const char * const *); 60 | 61 | #define STRLIST_FIRST(head) ((head)->first) 62 | #define STRLIST_NEXT(elem) ((elem)->next) 63 | #define STRLIST_FOREACH(var, head) \ 64 | for ((var) = STRLIST_FIRST(head); \ 65 | (var) != NULL; \ 66 | (var) = STRLIST_NEXT(var)) 67 | #define STRLIST_FOREACH_MUTABLE(var, head, var2) \ 68 | for ((var) = STRLIST_FIRST(head); \ 69 | (var) != NULL && ((var2) = STRLIST_NEXT(var), 1); \ 70 | (var) = (var2)) 71 | #define STRLIST_EMPTY(head) (STRLIST_FIRST(head) == NULL) 72 | 73 | #endif /* STRLIST_H */ 74 | -------------------------------------------------------------------------------- /os/openbsd/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | * Various settings that controls how the C compiler works. 30 | */ 31 | 32 | /* common cpp predefines */ 33 | #define CPPADD { "-D__OpenBSD__", "-D__ELF__", NULL, } 34 | #define DYNLINKLIB "/usr/libexec/ld.so" 35 | #define CRTBEGIN_T CRTBEGIN 36 | #define CRTEND_T CRTEND 37 | #define CRTI 0 /* OpenBSD does not use this */ 38 | #define CRTN 0 /* OpenBSD does not use this */ 39 | 40 | #ifdef LANG_F77 41 | #define F77LIBLIST { "-L/usr/local/lib", "-lF77", "-lI77", "-lm", "-lc", NULL }; 42 | #endif 43 | 44 | #define PCC_EARLY_SETUP { kflag = 1; } 45 | 46 | #if defined(mach_amd64) 47 | #define CPPMDADD { "-D__amd64__", "-D__amd64", "-D__x86_64__", "-D__x86_64", \ 48 | "-D__LP64__", "-D_LP64", NULL, } 49 | #elif defined(mach_i386) 50 | #define CPPMDADD { "-D__i386__", NULL, } 51 | #elif defined(mach_vax) 52 | #define CPPMDADD { "-D__vax__", NULL, } 53 | #elif defined(mach_powerpc) 54 | #define CPPMDADD { "-D__powerpc__", NULL } 55 | #elif defined(mach_sparc64) 56 | #define CPPMDADD { "-D__sparc64__", "-D__LP64__", "-D_LP64", NULL } 57 | #elif defined(mach_m68k) 58 | #define CPPMDADD { "-D__mc68000__", "-D__mc68020__", "-D__m68k__", NULL } 59 | #define STARTLABEL "_start" 60 | #elif defined(mach_mips64) 61 | #ifdef TARGET_BIG_ENDIAN 62 | #define CPPMDADD { "-D__MIPSEB__", "-D__mips__", "-D__mips64__", "-D__LP64__", \ 63 | "-D_LP64", NULL } 64 | #else 65 | #define CPPMDADD { "-D__MIPSEL__", "-D__mips__", "-D__mipsel__", \ 66 | "-D__mips64__", "-D__mips64el__", "-D__LP64__", "-D_LP64", \ 67 | NULL } 68 | #endif 69 | #else 70 | #error defines for arch missing 71 | #endif 72 | -------------------------------------------------------------------------------- /os/win32/pcc.iss: -------------------------------------------------------------------------------- 1 | [Setup] 2 | AppName={#AppName} 3 | AppID={#AppNameLower} 4 | AppVerName={#AppName} {#AppVersion} 5 | AppPublisher=PCC Project 6 | AppPublisherURL=http://pcc.ludd.ltu.se/ 7 | DefaultDirName={pf}\{#AppNameLower} 8 | DefaultGroupName={#AppName} 9 | Compression=lzma/ultra 10 | InternalCompressLevel=ultra 11 | SolidCompression=yes 12 | OutputDir=. 13 | OutputBaseFilename={#AppNameLower}-{#AppVersion}-win32 14 | ChangesEnvironment=yes 15 | 16 | [Files] 17 | Source: "c:\Program Files\{#AppNameLower}\*.*"; DestDir: {app}; Flags: recursesubdirs 18 | 19 | [Icons] 20 | Name: {group}\{cm:UninstallProgram, {#AppName}}; FileName: {uninstallexe} 21 | 22 | [Registry] 23 | Root: HKLM; Subkey: System\CurrentControlSet\Control\Session Manager\Environment; ValueName: {#AppName}DIR; ValueType: string; ValueData: {app}; Flags: deletevalue 24 | 25 | [Tasks] 26 | Name: modifypath; Description: Add application directory to your system path; Flags: unchecked 27 | 28 | [Code] 29 | 30 | // Jared Breland 31 | // http://www.legroom.net/software/modpath 32 | 33 | procedure ModPath(BinDir : String); 34 | var 35 | oldpath : String; 36 | newpath : String; 37 | pathArr : TArrayOfString; 38 | i : Integer; 39 | begin 40 | RegQueryStringValue(HKEY_LOCAL_MACHINE, 'System\CurrentControlSet\Control\Session Manager\Environment', 'Path', oldpath); 41 | oldpath := oldpath + ';'; 42 | i := 0; 43 | while (Pos(';', oldpath) > 0) do begin 44 | SetArrayLength(pathArr, i+1); 45 | pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath) - 1); 46 | oldpath := Copy(oldpath, Pos(';', oldpath) + 1, Length(oldpath)); 47 | i := i + 1; 48 | 49 | if BinDir = pathArr[i-1] then 50 | if IsUninstaller() = true then begin 51 | continue; 52 | end else begin 53 | abort; 54 | end; 55 | 56 | if i = 1 then begin 57 | newpath := pathArr[i-1]; 58 | end else begin 59 | newpath := newpath + ';' + pathArr[i-1]; 60 | end; 61 | end; 62 | 63 | if IsUninstaller() = false then 64 | newpath := newpath + ';' + BinDir; 65 | 66 | RegWriteStringValue(HKEY_LOCAL_MACHINE, 'System\CurrentControlSet\Control\Session Manager\Environment', 'Path', newpath); 67 | end; 68 | 69 | procedure CurStepChanged(CurStep : TSetupStep); 70 | var 71 | appdir : String; 72 | begin 73 | if CurStep = ssPostInstall then 74 | if IsTaskSelected('modifypath') then begin 75 | appdir := ExpandConstant('{app}'); 76 | ModPath(appdir + '\bin'); 77 | SaveStringToFile(appdir + '\uninsTasks.txt', WizardSelectedTasks(False), False); 78 | end; 79 | end; 80 | 81 | procedure CurUninstallStepChanged(CurUninstallStep : TUninstallStep); 82 | var 83 | appdir : String; 84 | selectedTasks : String; 85 | begin 86 | if CurUninstallStep = usUninstall then begin 87 | appdir := ExpandConstant('{app}'); 88 | if LoadStringFromFile(appdir + '\uninsTasks.txt', selectedTasks) then 89 | if (Pos('modifypath', selectedTasks) > 0) then 90 | ModPath(appdir + '\bin'); 91 | DeleteFile(appdir + '\uninsTasks.txt') 92 | end; 93 | end; 94 | -------------------------------------------------------------------------------- /f77/fcom/ftypes.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /* 3 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * Redistributions of source code and documentation must retain the above 10 | * copyright notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditionsand the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed or owned by Caldera 17 | * International, Inc. 18 | * Neither the name of Caldera International, Inc. nor the names of other 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 23 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | /* variable types 36 | * numeric assumptions: 37 | * int < reals < complexes 38 | * TYDREAL-TYREAL = TYDCOMPLEX-TYCOMPLEX 39 | */ 40 | 41 | #ifndef _FTYPES_H_ 42 | #define _FTYPES_H_ 43 | 44 | 45 | #define TYUNKNOWN 0 46 | #define TYADDR 1 47 | #define TYSHORT 2 48 | #define TYLONG 3 49 | #define TYREAL 4 50 | #define TYDREAL 5 51 | #define TYCOMPLEX 6 52 | #define TYDCOMPLEX 7 53 | #define TYLOGICAL 8 54 | #define TYCHAR 9 55 | #define TYSUBR 10 56 | #define TYERROR 11 57 | 58 | #define NTYPES (TYERROR+1) 59 | 60 | /* 61 | * Type conversion from pcc to f77 internal format. 62 | */ 63 | #define FSZADDR (SZPOINT(0)/SZCHAR) /* XXX - typecheck? */ 64 | #define FSZSHORT (SZSHORT/SZCHAR) 65 | #define FSZINT (SZINT/SZCHAR) 66 | #define FSZLONG (SZLONG/SZCHAR) 67 | #define ALIADDR (ALPOINT/ALCHAR) 68 | #define ALISHORT (ALSHORT/ALCHAR) 69 | #define ALILONG (ALLONG/ALCHAR) 70 | #define ALIDOUBLE (ALDOUBLE/ALCHAR) 71 | 72 | #ifndef SZINT 73 | #include "macdefs.h" 74 | #endif 75 | #if SZINT == SZSHORT 76 | #define TYINT TYSHORT 77 | #else /* SZLONG >= SZINT */ 78 | #define TYINT TYLONG 79 | #endif 80 | 81 | #define TYLENG TYLONG 82 | #endif /* !_FTYPES_H_ */ 83 | -------------------------------------------------------------------------------- /f77/fcom/gram.expr: -------------------------------------------------------------------------------- 1 | funarglist: 2 | { $$ = 0; } 3 | | funargs 4 | ; 5 | 6 | funargs: expr 7 | { $$ = mkchain($1, 0); } 8 | | funargs SCOMMA expr 9 | { $$ = hookup($1, mkchain($3,0) ); } 10 | ; 11 | 12 | 13 | expr: uexpr 14 | | SLPAR expr SRPAR { $$ = $2; } 15 | | complex_const 16 | ; 17 | 18 | uexpr: lhs 19 | | simple_const 20 | | expr addop expr %prec SPLUS 21 | { $$ = mkexpr($2, $1, $3); } 22 | | expr SSTAR expr 23 | { $$ = mkexpr(OPSTAR, $1, $3); } 24 | | expr SSLASH expr 25 | { $$ = mkexpr(OPSLASH, $1, $3); } 26 | | expr SPOWER expr 27 | { $$ = mkexpr(OPPOWER, $1, $3); } 28 | | addop expr %prec SSTAR 29 | { if($1 == OPMINUS) 30 | $$ = mkexpr(OPNEG, $2, 0); 31 | else $$ = $2; 32 | } 33 | | expr relop expr %prec SEQ 34 | { $$ = mkexpr($2, $1, $3); } 35 | | expr SEQV expr 36 | { $$ = mkexpr(OPEQV, $1,$3); } 37 | | expr SNEQV expr 38 | { $$ = mkexpr(OPNEQV, $1, $3); } 39 | | expr SOR expr 40 | { $$ = mkexpr(OPOR, $1, $3); } 41 | | expr SAND expr 42 | { $$ = mkexpr(OPAND, $1, $3); } 43 | | SNOT expr 44 | { $$ = mkexpr(OPNOT, $2, 0); } 45 | | expr SCONCAT expr 46 | { $$ = mkexpr(OPCONCAT, $1, $3); } 47 | ; 48 | 49 | addop: SPLUS { $$ = OPPLUS; } 50 | | SMINUS { $$ = OPMINUS; } 51 | ; 52 | 53 | relop: SEQ { $$ = OPEQ; } 54 | | SGT { $$ = OPGT; } 55 | | SLT { $$ = OPLT; } 56 | | SGE { $$ = OPGE; } 57 | | SLE { $$ = OPLE; } 58 | | SNE { $$ = OPNE; } 59 | ; 60 | 61 | lhs: name 62 | { $$ = mkprim($1, 0, 0, 0); } 63 | | name SLPAR opt_expr SCOLON opt_expr SRPAR 64 | { $$ = mkprim($1, 0, $3, $5); } 65 | | name SLPAR funarglist SRPAR 66 | { $$ = mkprim($1, mklist($3), 0, 0); } 67 | | name SLPAR funarglist SRPAR SLPAR opt_expr SCOLON opt_expr SRPAR 68 | { $$ = mkprim($1, mklist($3), $6, $8); } 69 | ; 70 | 71 | opt_expr: 72 | { $$ = 0; } 73 | | expr 74 | ; 75 | 76 | simple: name 77 | { if($1->vclass == CLPARAM) 78 | $$ = cpexpr($1->b_param.paramval); 79 | } 80 | | simple_const 81 | ; 82 | 83 | simple_const: STRUE { $$ = mklogcon(1); } 84 | | SFALSE { $$ = mklogcon(0); } 85 | | SHOLLERITH { $$ = mkstrcon(toklen, token); } 86 | | SICON { $$ = mkintcon( convci(toklen, token) ); } 87 | | SRCON { $$ = mkrealcon(TYREAL, convcd(toklen, token)); } 88 | | SDCON { $$ = mkrealcon(TYDREAL, convcd(toklen, token)); } 89 | ; 90 | 91 | complex_const: SLPAR uexpr SCOMMA uexpr SRPAR 92 | { $$ = mkcxcon($2,$4); } 93 | ; 94 | 95 | bit_const: SHEXCON 96 | { $$ = mkbitcon(4, toklen, token); } 97 | | SOCTCON 98 | { $$ = mkbitcon(3, toklen, token); } 99 | | SBITCON 100 | { $$ = mkbitcon(1, toklen, token); } 101 | ; 102 | 103 | fexpr: unpar_fexpr 104 | | SLPAR fexpr SRPAR 105 | { $$ = $2; } 106 | ; 107 | 108 | unpar_fexpr: lhs 109 | | simple_const 110 | | fexpr addop fexpr %prec SPLUS 111 | { $$ = mkexpr($2, $1, $3); } 112 | | fexpr SSTAR fexpr 113 | { $$ = mkexpr(OPSTAR, $1, $3); } 114 | | fexpr SSLASH fexpr 115 | { $$ = mkexpr(OPSLASH, $1, $3); } 116 | | fexpr SPOWER fexpr 117 | { $$ = mkexpr(OPPOWER, $1, $3); } 118 | | addop fexpr %prec SSTAR 119 | { if($1 == OPMINUS) 120 | $$ = mkexpr(OPNEG, $2, 0); 121 | else $$ = $2; 122 | } 123 | | fexpr SCONCAT fexpr 124 | { $$ = mkexpr(OPCONCAT, $1, $3); } 125 | ; 126 | -------------------------------------------------------------------------------- /cc/cpp/tests/res12: -------------------------------------------------------------------------------- 1 | 2 | # 1 "" 3 | 4 | # 1 "" 5 | 6 | 7 | 8 | 9 | 10 | 2 2 2 2 2; 11 | # 19 "" 12 | (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, (0 + 8) + 0, 13 | -------------------------------------------------------------------------------- /f77/fcom/gram.io: -------------------------------------------------------------------------------- 1 | /* Input/Output Statements */ 2 | 3 | io: io1 4 | { endio(); } 5 | ; 6 | 7 | io1: iofmove ioctl 8 | | iofmove unpar_fexpr 9 | { ioclause(IOSUNIT, $2); endioctl(); } 10 | | iofctl ioctl 11 | | read ioctl 12 | { doio(NULL); } 13 | | read ioctl inlist 14 | { doio($3); } 15 | | read infmt SCOMMA inlist 16 | { doio($4); } 17 | | read ioctl SCOMMA inlist 18 | { doio($4); } 19 | | write ioctl 20 | { doio(NULL); } 21 | | write ioctl outlist 22 | { doio($3); } 23 | | print 24 | { doio(NULL); } 25 | | print SCOMMA outlist 26 | { doio($3); } 27 | ; 28 | 29 | iofmove: fmkwd end_spec in_ioctl 30 | ; 31 | 32 | fmkwd: SBACKSPACE 33 | { iostmt = IOREWIND; } 34 | | SREWIND 35 | { iostmt = IOREWIND; } 36 | | SENDFILE 37 | { iostmt = IOENDFILE; } 38 | ; 39 | 40 | iofctl: ctlkwd end_spec in_ioctl 41 | ; 42 | 43 | ctlkwd: SINQUIRE 44 | { iostmt = IOINQUIRE; } 45 | | SOPEN 46 | { iostmt = IOOPEN; } 47 | | SCLOSE 48 | { iostmt = IOCLOSE; } 49 | ; 50 | 51 | infmt: unpar_fexpr 52 | { 53 | ioclause(IOSUNIT, NULL); 54 | ioclause(IOSFMT, $1); 55 | endioctl(); 56 | } 57 | | SSTAR 58 | { 59 | ioclause(IOSUNIT, NULL); 60 | ioclause(IOSFMT, NULL); 61 | endioctl(); 62 | } 63 | ; 64 | 65 | ioctl: SLPAR fexpr SRPAR 66 | { ioclause(IOSUNIT, $2); endioctl(); } 67 | | SLPAR ctllist SRPAR 68 | { endioctl(); } 69 | ; 70 | 71 | ctllist: ioclause SCOMMA ioclause 72 | | ctllist SCOMMA ioclause 73 | ; 74 | 75 | ioclause: fexpr 76 | { ioclause(IOSPOSITIONAL, $1); } 77 | | SSTAR 78 | { ioclause(IOSPOSITIONAL, NULL); } 79 | | nameeq expr 80 | { ioclause($1, $2); } 81 | | nameeq SSTAR 82 | { ioclause($1, NULL); } 83 | ; 84 | 85 | nameeq: SNAMEEQ 86 | { $$ = iocname(); } 87 | ; 88 | 89 | read: SREAD end_spec in_ioctl 90 | { iostmt = IOREAD; } 91 | ; 92 | 93 | write: SWRITE end_spec in_ioctl 94 | { iostmt = IOWRITE; } 95 | ; 96 | 97 | print: SPRINT end_spec fexpr in_ioctl 98 | { 99 | iostmt = IOWRITE; 100 | ioclause(IOSUNIT, NULL); 101 | ioclause(IOSFMT, $3); 102 | endioctl(); 103 | } 104 | | SPRINT end_spec SSTAR in_ioctl 105 | { 106 | iostmt = IOWRITE; 107 | ioclause(IOSUNIT, NULL); 108 | ioclause(IOSFMT, NULL); 109 | endioctl(); 110 | } 111 | ; 112 | 113 | inlist: inelt 114 | { $$ = mkchain($1,0); } 115 | | inlist SCOMMA inelt 116 | { $$ = hookup($1, mkchain($3,0)); } 117 | ; 118 | 119 | inelt: lhs 120 | | SLPAR inlist SCOMMA dospec SRPAR 121 | { $$ = mkiodo($4,$2); } 122 | ; 123 | 124 | outlist: uexpr 125 | { $$ = mkchain($1, 0); } 126 | | other 127 | { $$ = mkchain($1, 0); } 128 | | out2 129 | ; 130 | 131 | out2: uexpr SCOMMA uexpr 132 | { $$ = mkchain($1, mkchain($3, 0) ); } 133 | | uexpr SCOMMA other 134 | { $$ = mkchain($1, mkchain($3, 0) ); } 135 | | other SCOMMA uexpr 136 | { $$ = mkchain($1, mkchain($3, 0) ); } 137 | | other SCOMMA other 138 | { $$ = mkchain($1, mkchain($3, 0) ); } 139 | | out2 SCOMMA uexpr 140 | { $$ = hookup($1, mkchain($3, 0) ); } 141 | | out2 SCOMMA other 142 | { $$ = hookup($1, mkchain($3, 0) ); } 143 | ; 144 | 145 | other: complex_const 146 | | SLPAR uexpr SCOMMA dospec SRPAR 147 | { $$ = mkiodo($4, mkchain($2, 0) ); } 148 | | SLPAR other SCOMMA dospec SRPAR 149 | { $$ = mkiodo($4, mkchain($2, 0) ); } 150 | | SLPAR out2 SCOMMA dospec SRPAR 151 | { $$ = mkiodo($4, $2); } 152 | ; 153 | 154 | in_ioctl: 155 | { startioctl(); } 156 | ; 157 | -------------------------------------------------------------------------------- /common/unicode.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /* 3 | * Copyright (c) 2014 Eric Olson 4 | * Some rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in 14 | * the documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 20 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 21 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 27 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | #include "pass1.h" 34 | #include "manifest.h" 35 | #include "unicode.h" 36 | 37 | /* 38 | * decode 32-bit code point from UTF-8 39 | * move pointer 40 | */ 41 | long 42 | u82cp(char **q) 43 | { 44 | unsigned char *t = (unsigned char *)*q; 45 | unsigned long c, r; 46 | int i, sz; 47 | 48 | if (*t == '\\') 49 | c = esccon((char **)&t); 50 | else 51 | c = *t++; 52 | 53 | /* always eat the first value */ 54 | *q = (char *)t; 55 | 56 | if (c > 0x7F) { 57 | if ((c & 0xE0) == 0xC0) { 58 | sz = 2; 59 | r = c & 0x1F; 60 | } else if ((c & 0xF0) == 0xE0) { 61 | sz = 3; 62 | r = c & 0x0F; 63 | } else if ((c & 0xF8) == 0xF0) { 64 | sz = 4; 65 | r = c & 0x07; 66 | } else if ((c & 0xFC) == 0xF8) { 67 | sz = 5; 68 | r = c & 0x03; 69 | } else if ((c & 0xFE) == 0xFC) { 70 | sz = 6; 71 | r = c & 0x01; 72 | } else { 73 | u8error("invalid utf-8 prefix"); 74 | return 0xFFFFUL; 75 | } 76 | 77 | for (i = 1; i < sz; i++) { 78 | if (*t == '\\') 79 | c = esccon((char **)&t); 80 | else 81 | c = *t++; 82 | 83 | if ((c & 0xC0) == 0x80) { 84 | r = (r << 6) + (c & 0x3F); 85 | } else { 86 | u8error("utf-8 encoding %d bytes too short", sz - i); 87 | return 0xFFFFUL; 88 | } 89 | } 90 | 91 | *q = (char *)t; 92 | } else { 93 | r = c; 94 | } 95 | 96 | return r; 97 | } 98 | 99 | /* 100 | * Create UTF-16 from unicode number. 101 | * Expects s to point to two words. 102 | */ 103 | void 104 | cp2u16(long num, unsigned short *s) 105 | { 106 | s[0] = s[1] = 0; 107 | if (num <= 0xd7ff || (num >= 0xe000 && num <= 0xffffL)) { 108 | *s = (unsigned short)num; 109 | } else if (num >= 0x010000L && num <= 0x10ffffL) { 110 | num -= 0x010000L; 111 | s[0] = (unsigned short)((num >> 10) + 0xd800); 112 | s[1] = (unsigned short)((num & 0x3ff) + 0xdc00); 113 | } else if (num > 0x10ffffL) 114 | werror("illegal UTF-16 value"); 115 | } 116 | -------------------------------------------------------------------------------- /f77/fcom/error.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /* 3 | * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * Redistributions of source code and documentation must retain the above 10 | * copyright notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed or owned by Caldera 17 | * International, Inc. 18 | * Neither the name of Caldera International, Inc. nor the names of other 19 | * contributors may be used to endorse or promote products derived from 20 | * this software without specific prior written permission. 21 | * 22 | * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA 23 | * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 32 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | * POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include 37 | 38 | #include "defines.h" 39 | #include "defs.h" 40 | 41 | void 42 | warn(char *s, ...) 43 | { 44 | va_list ap; 45 | 46 | if(nowarnflag) 47 | return; 48 | 49 | va_start(ap, s); 50 | fprintf(diagfile, "Warning on line %d of %s: ", lineno, infname); 51 | vfprintf(diagfile, s, ap); 52 | fprintf(diagfile, "\n"); 53 | va_end(ap); 54 | ++nwarn; 55 | } 56 | 57 | void 58 | err(char *s, ...) 59 | { 60 | va_list ap; 61 | 62 | va_start(ap, s); 63 | fprintf(diagfile, "Error on line %d of %s: ", lineno, infname); 64 | vfprintf(diagfile, s, ap); 65 | fprintf(diagfile, "\n"); 66 | va_end(ap); 67 | ++nerr; 68 | } 69 | 70 | void 71 | yyerror(s) 72 | char *s; 73 | { err(s); } 74 | 75 | 76 | void 77 | dclerr(s, v) 78 | char *s; 79 | struct bigblock *v; 80 | { 81 | char buff[100]; 82 | 83 | if(v) { 84 | sprintf(buff, "Declaration error for %s: %s", 85 | varstr(VL, v->b_name.varname), s); 86 | err( buff); 87 | } else 88 | err1("Declaration error %s", s); 89 | } 90 | 91 | 92 | void 93 | execerr(char *s, ...) 94 | { 95 | va_list ap; 96 | 97 | va_start(ap, s); 98 | fprintf(diagfile, "Error on line %d of %s: Execution error ", 99 | lineno, infname); 100 | vfprintf(diagfile, s, ap); 101 | fprintf(diagfile, "\n"); 102 | va_end(ap); 103 | ++nerr; 104 | } 105 | 106 | void 107 | fatal(char *s, ...) 108 | { 109 | va_list ap; 110 | 111 | va_start(ap, s); 112 | fprintf(diagfile, "Compiler error line %d of %s: ", lineno, infname); 113 | vfprintf(diagfile, s, ap); 114 | fprintf(diagfile, "\n"); 115 | va_end(ap); 116 | 117 | if(debugflag) 118 | abort(); 119 | done(3); 120 | exit(3); 121 | } 122 | -------------------------------------------------------------------------------- /os/minix/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /* 3 | * Escrit per Antoine Leca pel projecte PCC, 2011-03. 4 | * Copyright (C) 2011 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | * Various settings that controls how the C compiler works. 30 | * 31 | * MINIX (http://www.minix3.org), both Classic a.out=PC/IX and ELF 32 | */ 33 | 34 | #ifdef ELFABI 35 | /* MINIX versions 3.2 (2011) and up, using NetBSD userland. */ 36 | 37 | /* common cpp predefines */ 38 | #define CPPADD { "-D__minix", "-D__ELF__", NULL } 39 | 40 | #define DYNLINKLIB "/usr/libexec/ld.elf_so" 41 | 42 | #define CRTEND_T "crtend.o" 43 | 44 | #define DEFLIBS { "-lc", NULL } 45 | #define DEFPROFLIBS { "-lc_p", NULL } 46 | #define DEFCXXLIBS { "-lp++", "-lc", NULL } 47 | 48 | #if defined(mach_amd64) 49 | #include "../inc/amd64.h" 50 | #define PCC_SIZE_TYPE "unsigned long" 51 | #define PCC_PTRDIFF_TYPE "long" 52 | #elif defined(mach_arm) 53 | #define CPPMDADD { "-D__arm__", NULL, } 54 | #elif defined(mach_i386) 55 | #define CPPMDADD { "-D__i386", "-D__i386__", NULL, } 56 | #else 57 | #error defines for arch missing 58 | #endif 59 | 60 | #ifndef PCC_WINT_TYPE 61 | #define PCC_WINT_TYPE "int" 62 | #endif 63 | #ifndef PCC_SIZE_TYPE 64 | #define PCC_SIZE_TYPE "unsigned int" 65 | #endif 66 | #ifndef PCC_PTRDIFF_TYPE 67 | #define PCC_PTRDIFF_TYPE "int" 68 | #endif 69 | 70 | #elif defined(AOUTABI) 71 | /* MINIX 2 or 3.1.x, a.out-like format derived from PC/IX. */ 72 | 73 | /* common cpp predefines */ 74 | #define CPPADD { "-D__minix", NULL } 75 | 76 | /* linker stuff */ 77 | #define STARTLABEL "crtso" 78 | #define CRT0 "crtso.o" 79 | #ifdef notyet 80 | #define GCRT0 "/usr/lib/pcc/gcrtso.o" 81 | #endif 82 | 83 | #define CRTBEGIN 0 84 | #define CRTEND 0 85 | #define CRTBEGIN_S 0 86 | #define CRTEND_S 0 87 | #define CRTBEGIN_T 0 88 | #define CRTEND_T 0 89 | 90 | #define CRTI 0 91 | #define CRTN "end.a" 92 | 93 | #define DEFLIBS {"-lc", "-lpccsoftfloat", "-lpcc", "-lc", NULL } 94 | 95 | #if defined(mach_i386) 96 | #define CPPMDADD { "-D__i386", "-D__i386__", \ 97 | "-D_EM_WSIZE=4", "-D_EM_PSIZE=4", "-D_EM_LSIZE=4", \ 98 | "-D_EM_SSIZE=2", "-D_EM_FSIZE=4", "-D_EM_DSIZE=8", \ 99 | NULL, } 100 | #else 101 | #define CPPMDADD { "-D__i86", \ 102 | "-D_EM_WSIZE=2", "-D_EM_PSIZE=2", "-D_EM_LSIZE=4", \ 103 | "-D_EM_SSIZE=2", "-D_EM_FSIZE=4", "-D_EM_DSIZE=8", \ 104 | NULL, } 105 | #endif 106 | 107 | #else 108 | #error defines for ABI missing 109 | #endif 110 | -------------------------------------------------------------------------------- /os/linux/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /* 29 | * Various settings that controls how the C compiler works. 30 | */ 31 | 32 | /* common cpp predefines */ 33 | #define CPPADD { "-D__linux__", "-D__ELF__", NULL, } 34 | 35 | #define CRT0 "crt1.o" 36 | #define GCRT0 "gcrt1.o" 37 | 38 | #define STARTLABEL "_start" 39 | 40 | #if defined(mach_arm) 41 | #define CPPMDADD { "-D__arm__", NULL, } 42 | #define DYNLINKLIB "/lib/ld-linux.so.2" 43 | #elif defined(mach_i386) 44 | #define CPPMDADD { "-D__i386__", NULL, } 45 | #define DYNLINKLIB "/lib/ld-linux.so.2" 46 | #define MUSL_DYLIB "/lib/ld-musl-i386.so.1" 47 | #elif defined(mach_powerpc) 48 | #define CPPMDADD { "-D__ppc__", NULL, } 49 | #define DYNLINKLIB "/lib/ld-linux.so.2" 50 | #define MUSL_DYLIB "/lib/ld-musl-powerpc.so.1" 51 | #elif defined(mach_amd64) 52 | #include "../inc/amd64.h" 53 | #define DYNLINKLIB "/lib64/ld-linux-x86-64.so.2" 54 | #define MUSL_DYLIB "/lib/ld-musl-x86_64.so.1" 55 | #ifndef MULTIARCH_PATH 56 | #define DEFLIBDIRS { "/usr/lib64/", 0 } 57 | #else 58 | #define DEFLIBDIRS { "/usr/lib64/", "/usr/lib/" MULTIARCH_PATH "/", 0 } 59 | #define STDINC "/usr/include", "/usr/include/x86_64-linux-gnu" 60 | #endif 61 | #elif defined(mach_mips) 62 | #define CPPMDADD { "-D__mips__", NULL, } 63 | #define DYNLINKLIB "/lib/ld.so.1" 64 | #define MUSL_ROOT "/lib/ld-musl-mips" 65 | #define MUSL_EL "el" 66 | #define MUSL_SF "-sf" 67 | #elif defined(mach_aarch64) 68 | #define CPPMDADD { "-D__aarch64__", NULL, } 69 | #define MUSL_DYLIB "/lib/ld-musl-aarch64.so.1" 70 | #elif defined(mach_m68k) 71 | #define CPPMDADD { "-D__m68k__", NULL, } 72 | #else 73 | #error defines for arch missing 74 | #endif 75 | 76 | /* 77 | * When USE_MUSL is defined, we either provide MUSL_DYLIB, or 78 | * code to construct the dynamic linker name at runtime 79 | */ 80 | #ifdef USE_MUSL 81 | #ifdef MUSL_DYLIB 82 | #define DYNLINKLIB MUSL_DYLIB 83 | #else 84 | #ifndef MUSL_EB 85 | #define MUSL_EB NULL 86 | #endif 87 | #ifndef MUSL_EL 88 | #define MUSL_EL NULL 89 | #endif 90 | #ifndef MUSL_SF 91 | #define MUSL_SF NULL 92 | #endif 93 | #ifndef MUSL_HF 94 | #define MUSL_HF NULL 95 | #endif 96 | #ifndef MUSL_EXT 97 | #define MUSL_EXT ".so.1" 98 | #endif 99 | 100 | #define PCC_SETUP_LD_ARGS { \ 101 | char *t = MUSL_ROOT; \ 102 | t = cat(t, bigendian ? MUSL_EB : MUSL_EL); \ 103 | t = cat(t, softfloat ? MUSL_SF : MUSL_HF); \ 104 | dynlinklib = cat(t, MUSL_EXT); \ 105 | } 106 | #endif 107 | #endif 108 | -------------------------------------------------------------------------------- /os/sunos/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2008 Adam Hoka. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* 31 | * Various settings that controls how the C compiler works. 32 | */ 33 | 34 | /* common cpp predefines */ 35 | #ifdef __illumos__ 36 | #define CPPADD { "-Dunix", "-Dsun", "-D__SVR4", "-D__unix", "-D__sun", "-D__SunOS", "-D__illumos__", "-D__ELF__", NULL } 37 | #else 38 | #define CPPADD { "-Dunix", "-Dsun", "-D__SVR4", "-D__unix", "-D__sun", "-D__SunOS", "-D__ELF__", NULL } 39 | #endif 40 | 41 | /* TODO: _ _SunOS_5_6, _ _SunOS_5_7, _ _SunOS_5_8, _ _SunOS_5_9, _ _SunOS_5_10 */ 42 | 43 | /* host-dependent */ 44 | #define CRT0 "crt1.o" 45 | #define GCRT0 "gcrt1.o" 46 | #define CRTBEGIN 0 47 | #define CRTEND 0 48 | 49 | #ifdef __illumos__ 50 | #define STARTLABEL "_start" 51 | #endif 52 | 53 | #ifdef LANG_F77 54 | #define F77LIBLIST { "-L/usr/local/lib", "-lF77", "-lI77", "-lm", "-lc", NULL }; 55 | #endif 56 | 57 | /* host-independent */ 58 | #ifndef __illumos__ 59 | #define DYNLINKARG "-Bdynamic" 60 | #define DYNLINKLIB "/usr/lib/ld.so" 61 | #endif 62 | 63 | /* TODO: Detect if you're using the Sun assembler instead of the GNU assembler. 64 | The PCC_EARLY_AS_ARGS below assume the GNU assembler. PCC does generate 65 | assembly that the Sun assembler understands, so this assumption is 66 | unfounded. */ 67 | 68 | #if defined(mach_i386) 69 | #define CPPMDADD { "-D__i386__", "-D__i386", NULL, } 70 | #define PCC_EARLY_AS_ARGS strlist_append(&args, "--32"); 71 | #define PCC_SETUP_LD_ARGS { strlist_append(&early_linker_flags, "-Qy"); \ 72 | strlist_append(&early_linker_flags, "-Y"); \ 73 | strlist_append(&early_linker_flags, "P,/usr/ccs/lib:/lib:/usr/lib"); } 74 | #elif defined(mach_amd64) 75 | #define CPPMDADD { "-D__amd64__", "-D__amd64", "-D__x86_64__", "-D__x86_64", \ 76 | "-D__LP64__", "-D_LP64", NULL, } 77 | #define PCC_EARLY_AS_ARGS strlist_append(&args, "--64"); 78 | #define PCC_SETUP_LD_ARGS { strlist_append(&early_linker_flags, "-Qy"); \ 79 | strlist_append(&early_linker_flags, "-Y"); \ 80 | strlist_append(&early_linker_flags, \ 81 | "P,/usr/ccs/lib/amd64:/lib/amd64:/usr/lib/amd64"); } 82 | #ifndef CROSS_COMPILING 83 | #define LIBDIR "/usr/lib/amd64" 84 | #endif 85 | /* Let's keep it here in case of Polaris. ;) */ 86 | #elif defined(mach_powerpc) 87 | #define CPPMDADD { "-D__ppc__", NULL, } 88 | #elif defined(mach_sparc64) 89 | #define CPPMDADD { "-D__sparc64__", "-D__sparc", NULL, } 90 | #else 91 | #error defines for arch missing 92 | #endif 93 | -------------------------------------------------------------------------------- /os/netbsd/ccconfig.h: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /* 4 | * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se). 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. The name of the author may not be used to endorse or promote products 16 | * derived from this software without specific prior written permission 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* 31 | * Various settings that controls how the C compiler works. 32 | */ 33 | 34 | /* common cpp predefines */ 35 | #define CPPADD { "-D__NetBSD__", "-D__ELF__", NULL, } 36 | 37 | #ifdef LANG_F77 38 | #define F77LIBLIST { "-L/usr/local/lib", "-lF77", "-lI77", "-lm", "-lc", NULL }; 39 | #define STARTFILES { "/usr/lib/crt0.o", NULL } 40 | #define ENDFILES { NULL } 41 | #define DYNLINKER { "/usr/libexec/ld.elf_so", NULL } 42 | #define CRT0FILE "/usr/lib/crt0.o" 43 | #endif 44 | 45 | #define DYNLINKLIB "/usr/libexec/ld.elf_so" 46 | 47 | #define CRTEND_T "crtend.o" 48 | #define RCRT0 "crt0.o" 49 | 50 | #ifdef notdef /* NetBSD needs libpcc now */ 51 | #define DEFLIBS { "-lc", NULL } 52 | #define DEFPROFLIBS { "-lc_p", NULL } 53 | #define DEFCXXLIBS { "-lp++", "-lc", NULL } 54 | #endif 55 | 56 | #if defined(mach_amd64) 57 | #include "../inc/amd64.h" 58 | #elif defined(mach_arm) 59 | #define CPPMDADD { "-D__arm__", NULL, } 60 | #elif defined(mach_i386) 61 | #define CPPMDADD { "-D__i386__", NULL, } 62 | #define PCC_SIZE_TYPE "unsigned int" 63 | #define PCC_PTRDIFF_TYPE "int" 64 | #elif defined(mach_m68k) 65 | #define CPPMDADD { "-D__mc68000__", "-D__mc68020__", "-D__m68k__", NULL, } 66 | #undef DEFLIBS 67 | #define DEFLIBS { "-lc", "-lgcc", NULL } 68 | #define STARTLABEL "_start" 69 | #elif defined(mach_mips) 70 | #define CPPMDADD { "-D__mips__", NULL, } 71 | #elif defined(mach_mips64) 72 | #ifdef TARGET_BIG_ENDIAN 73 | #define CPPMDADD { "-D__MIPSEB__", "-D__mips__", "-D__mips64__", NULL, } 74 | #else 75 | #define CPPMDADD { "-D__MIPSEL__", "-D__mips__", "-D__mips64__", "-D__mipsel__", "-D__mips64el__", NULL, } 76 | #endif 77 | #elif defined(mach_pdp10) 78 | #define CPPMDADD { "-D__pdp10__", NULL, } 79 | #elif defined(mach_powerpc) 80 | #define CPPMDADD { "-D__ppc__", NULL, } 81 | #define STARTLABEL "_start" 82 | #elif defined(mach_riscv32) 83 | #define CPPMDADD { "-D__riscv__", "-D__riscv32__", NULL, } 84 | #elif defined(mach_vax) 85 | #define CPPMDADD { "-D__vax__", NULL, } 86 | #define PCC_EARLY_SETUP { kflag = 1; } 87 | #elif defined(mach_sparc64) 88 | #define CPPMDADD { "-D__sparc64__", NULL, } 89 | #else 90 | #error defines for arch missing 91 | #endif 92 | 93 | #ifndef PCC_WINT_TYPE 94 | #define PCC_WINT_TYPE "int" 95 | #endif 96 | #ifndef PCC_SIZE_TYPE 97 | #define PCC_SIZE_TYPE "unsigned long" 98 | #endif 99 | #ifndef PCC_PTRDIFF_TYPE 100 | #define PCC_PTRDIFF_TYPE "long" 101 | #endif 102 | -------------------------------------------------------------------------------- /arch/mips/order.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /* 3 | * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote products 15 | * derived from this software without specific prior written permission 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* 30 | * MIPS port by Jan Enoksson (janeno-1@student.ltu.se) and 31 | * Simon Olsson (simols-1@student.ltu.se) 2005. 32 | */ 33 | 34 | #include "pass2.h" 35 | 36 | /* 37 | * is it legal to make an OREG or NAME entry which has an offset of off, 38 | * (from a register of r), if the resulting thing had type t 39 | */ 40 | int 41 | notoff(TWORD t, int r, CONSZ off, char *cp) 42 | { 43 | /* 44 | * although the hardware doesn't permit offsets greater 45 | * than +/- 32K, the assembler fixes it for us. 46 | */ 47 | return 0; /* YES */ 48 | } 49 | 50 | /* 51 | * Turn a UMUL-referenced node into OREG. 52 | */ 53 | void 54 | offstar(NODE * p, int shape) 55 | { 56 | if (x2debug) 57 | printf("offstar(%p)\n", p); 58 | 59 | if (p->n_op == PLUS || p->n_op == MINUS) { 60 | if (p->n_right->n_op == ICON) { 61 | if (isreg(p->n_left) == 0) 62 | (void)geninsn(p->n_left, INAREG); 63 | /* Converted in ormake() */ 64 | return; 65 | } 66 | } 67 | (void)geninsn(p, INAREG); 68 | } 69 | 70 | /* 71 | * Do the actual conversion of offstar-found OREGs into real OREGs. 72 | */ 73 | void 74 | myormake(NODE * q) 75 | { 76 | if (x2debug) 77 | printf("myormake(%p)\n", q); 78 | } 79 | 80 | /* 81 | * Shape matches for UMUL. Cooperates with offstar(). 82 | */ 83 | int 84 | shumul(NODE *p, int shape) 85 | { 86 | if (x2debug) 87 | printf("shumul(%p)\n", p); 88 | 89 | /* Always turn it into OREG */ 90 | if (shape & SOREG) 91 | return SROREG; 92 | return SRNOPE; 93 | } 94 | 95 | /* 96 | * Rewrite operations on binary operators (like +, -, etc...). 97 | * Called as a result of table lookup. 98 | */ 99 | int 100 | setbin(NODE * p) 101 | { 102 | 103 | if (x2debug) 104 | printf("setbin(%p)\n", p); 105 | return 0; 106 | 107 | } 108 | 109 | /* setup for assignment operator */ 110 | int 111 | setasg(NODE * p, int cookie) 112 | { 113 | if (x2debug) 114 | printf("setasg(%p)\n", p); 115 | return (0); 116 | } 117 | 118 | /* setup for unary operator */ 119 | int 120 | setuni(NODE * p, int cookie) 121 | { 122 | return 0; 123 | } 124 | 125 | /* 126 | * Set evaluation order of a binary node if it differs from default. 127 | */ 128 | int 129 | setorder(NODE * p) 130 | { 131 | return 0; /* nothing differs */ 132 | } 133 | 134 | /* 135 | * Set registers "live" at function calls (like arguments in registers). 136 | * This is for liveness analysis of registers. 137 | */ 138 | int * 139 | livecall(NODE *p) 140 | { 141 | static int r[1] = { -1 }; /* Terminate with -1 */ 142 | 143 | return &r[0]; 144 | } 145 | 146 | /* 147 | * Signal whether the instruction is acceptable for this target. 148 | */ 149 | int 150 | acceptable(struct optab *op) 151 | { 152 | return 1; 153 | } 154 | -------------------------------------------------------------------------------- /arch/mips64/order.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /* 3 | * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote products 15 | * derived from this software without specific prior written permission 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* 30 | * MIPS port by Jan Enoksson (janeno-1@student.ltu.se) and 31 | * Simon Olsson (simols-1@student.ltu.se) 2005. 32 | * 33 | * Extended to MIPS64 by Brian Callahan 2016. 34 | */ 35 | 36 | #include "pass2.h" 37 | 38 | /* 39 | * is it legal to make an OREG or NAME entry which has an offset of off, 40 | * (from a register of r), if the resulting thing had type t 41 | */ 42 | int 43 | notoff(TWORD t, int r, CONSZ off, char *cp) 44 | { 45 | /* 46 | * although the hardware doesn't permit offsets greater 47 | * than +/- 32K, the assembler fixes it for us. 48 | */ 49 | return 0; /* YES */ 50 | } 51 | 52 | /* 53 | * Turn a UMUL-referenced node into OREG. 54 | */ 55 | void 56 | offstar(NODE * p, int shape) 57 | { 58 | if (x2debug) 59 | printf("offstar(%p)\n", p); 60 | 61 | if (p->n_op == PLUS || p->n_op == MINUS) { 62 | if (p->n_right->n_op == ICON) { 63 | if (isreg(p->n_left) == 0) 64 | (void)geninsn(p->n_left, INAREG); 65 | /* Converted in ormake() */ 66 | return; 67 | } 68 | } 69 | (void)geninsn(p, INAREG); 70 | } 71 | 72 | /* 73 | * Do the actual conversion of offstar-found OREGs into real OREGs. 74 | */ 75 | void 76 | myormake(NODE * q) 77 | { 78 | if (x2debug) 79 | printf("myormake(%p)\n", q); 80 | } 81 | 82 | /* 83 | * Shape matches for UMUL. Cooperates with offstar(). 84 | */ 85 | int 86 | shumul(NODE *p, int shape) 87 | { 88 | if (x2debug) 89 | printf("shumul(%p)\n", p); 90 | 91 | /* Always turn it into OREG */ 92 | if (shape & SOREG) 93 | return SROREG; 94 | return SRNOPE; 95 | } 96 | 97 | /* 98 | * Rewrite operations on binary operators (like +, -, etc...). 99 | * Called as a result of table lookup. 100 | */ 101 | int 102 | setbin(NODE * p) 103 | { 104 | 105 | if (x2debug) 106 | printf("setbin(%p)\n", p); 107 | return 0; 108 | 109 | } 110 | 111 | /* setup for assignment operator */ 112 | int 113 | setasg(NODE * p, int cookie) 114 | { 115 | if (x2debug) 116 | printf("setasg(%p)\n", p); 117 | return (0); 118 | } 119 | 120 | /* setup for unary operator */ 121 | int 122 | setuni(NODE * p, int cookie) 123 | { 124 | return 0; 125 | } 126 | 127 | /* 128 | * Set evaluation order of a binary node if it differs from default. 129 | */ 130 | int 131 | setorder(NODE * p) 132 | { 133 | return 0; /* nothing differs */ 134 | } 135 | 136 | /* 137 | * Set registers "live" at function calls (like arguments in registers). 138 | * This is for liveness analysis of registers. 139 | */ 140 | int * 141 | livecall(NODE *p) 142 | { 143 | static int r[1] = { -1 }; /* Terminate with -1 */ 144 | 145 | return &r[0]; 146 | } 147 | 148 | /* 149 | * Signal whether the instruction is acceptable for this target. 150 | */ 151 | int 152 | acceptable(struct optab *op) 153 | { 154 | return 1; 155 | } 156 | -------------------------------------------------------------------------------- /arch/nova/order.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | /* 3 | * Copyright (c) 2006 Anders Magnusson (ragge@ludd.luth.se). 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. The name of the author may not be used to endorse or promote products 15 | * derived from this software without specific prior written permission 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | 30 | # include "pass2.h" 31 | 32 | #include 33 | 34 | int canaddr(NODE *); 35 | 36 | /* is it legal to make an OREG or NAME entry which has an 37 | * offset of off, (from a register of r), if the 38 | * resulting thing had type t */ 39 | int 40 | notoff(TWORD t, int r, CONSZ off, char *cp) 41 | { 42 | if (x2debug) 43 | printf("notoff: t %x r %d off %ld\n", t, r, off); 44 | if (r < 2 || r > 3) 45 | return 1; /* can only index ac2/3 */ 46 | if (off < -128 || off > 127) 47 | return 1; 48 | return(0); /* YES */ 49 | } 50 | 51 | /* 52 | * Turn a UMUL-referenced node into OREG. 53 | * Be careful about register classes, this is a place where classes change. 54 | */ 55 | void 56 | offstar(NODE *p, int shape) 57 | { 58 | NODE *r; 59 | 60 | if (x2debug) 61 | printf("offstar(%p)\n", p); 62 | 63 | r = p->n_right; 64 | if ((p->n_op == PLUS || p->n_op == MINUS) && 65 | r->n_op == ICON && (getlval(r) >= -128 && getlval(r) <= 127)) { 66 | if (!isreg(p->n_left)) 67 | (void)geninsn(p->n_left, INAREG); 68 | return; 69 | } 70 | (void)geninsn(p, INAREG); 71 | } 72 | 73 | /* 74 | * Do the actual conversion of offstar-found OREGs into real OREGs. 75 | */ 76 | void 77 | myormake(NODE *q) 78 | { 79 | if (x2debug) 80 | printf("myormake(%p)\n", q); 81 | } 82 | 83 | /* 84 | * Shape matches for UMUL. Cooperates with offstar(). 85 | */ 86 | int 87 | shumul(NODE *p, int shape) 88 | { 89 | 90 | if (x2debug) 91 | printf("shumul(%p)\n", p); 92 | 93 | /* Turns currently anything into OREG on x86 */ 94 | if (shape & SOREG) 95 | return SROREG; 96 | return SRNOPE; 97 | } 98 | 99 | /* 100 | * Rewrite operations on binary operators (like +, -, etc...). 101 | * Called as a result of table lookup. 102 | */ 103 | int 104 | setbin(NODE *p) 105 | { 106 | 107 | if (x2debug) 108 | printf("setbin(%p)\n", p); 109 | return 0; 110 | 111 | } 112 | 113 | /* setup for assignment operator */ 114 | int 115 | setasg(NODE *p, int cookie) 116 | { 117 | if (x2debug) 118 | printf("setasg(%p)\n", p); 119 | return(0); 120 | } 121 | 122 | /* setup for unary operator */ 123 | int 124 | setuni(NODE *p, int cookie) 125 | { 126 | return 0; 127 | } 128 | 129 | /* 130 | * Set evaluation order of a binary node if it differs from default. 131 | */ 132 | int 133 | setorder(NODE *p) 134 | { 135 | return 0; 136 | } 137 | /* 138 | * Set registers "live" at function calls (like arguments in registers). 139 | * This is for liveness analysis of registers. 140 | */ 141 | int * 142 | livecall(NODE *p) 143 | { 144 | static int r[1] = { -1 }; /* Terminate with -1 */ 145 | 146 | return &r[0]; 147 | } 148 | 149 | /* 150 | * Signal whether the instruction is acceptable for this target. 151 | */ 152 | int 153 | acceptable(struct optab *op) 154 | { 155 | return 1; 156 | } 157 | -------------------------------------------------------------------------------- /f77/fcom/gram.head: -------------------------------------------------------------------------------- 1 | %{ 2 | 3 | #include "defines.h" 4 | #include "defs.h" 5 | 6 | static int nstars; 7 | static int ndim; 8 | static int vartype; 9 | static ftnint varleng; 10 | struct uux dims[8]; 11 | static struct labelblock *labarray[100]; 12 | static int lastwasbranch = NO; 13 | static int thiswasbranch = NO; 14 | 15 | %} 16 | 17 | /* Specify precedences and associativies. */ 18 | 19 | %left SCOMMA 20 | %nonassoc SCOLON 21 | %right SEQUALS 22 | %left SEQV SNEQV 23 | %left SOR 24 | %left SAND 25 | %left SNOT 26 | %nonassoc SLT SGT SLE SGE SEQ SNE 27 | %left SCONCAT 28 | %left SPLUS SMINUS 29 | %left SSTAR SSLASH 30 | %right SPOWER 31 | 32 | %union { 33 | struct labelblock *label; 34 | struct extsym *extsym; 35 | 36 | bigptr bigptr; 37 | chainp chainp; 38 | 39 | ftnint fint; 40 | char *str; 41 | char token; 42 | int num; 43 | } 44 | 45 | %type