mirror of
https://github.com/nArnoSNES/tcc-65816.git
synced 2024-10-08 07:54:59 +00:00
Initial Commit
This commit is contained in:
commit
7aeab42440
18
.travis.yml
Normal file
18
.travis.yml
Normal file
@ -0,0 +1,18 @@
|
||||
language: c
|
||||
|
||||
before_script:
|
||||
- ./configure --enable-cross
|
||||
|
||||
script: make 816-tcc
|
||||
|
||||
before_deploy:
|
||||
- zip -9ry 816-tcc.zip 816-tcc 816-opt.py
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api-key:
|
||||
- secure: "wrFShOH6+/tRv/uBJJlITaSPRa1Wh4WT1Sax3TgoohMzCARWS+ly/FyUvOFqBYA0qdInzw3Qhajd+FJxHikI0huyDCzeII/aata7CkuCw8tvteG6ayc2zcFGYDsD1lZovTZ0ryzpv65vnGc+I87jJ15v4sanb7rV0wIsABZ9UrIC1g26qINzSCQpbcLL7Saw3h0jhTOoDzwcSsBT+yVfJhGBgGpNsHOVf/YcJyLx6H+B2HSwcI0GA32k7sGBSM8H7oW37+XtCOi6Yl2kLhOXBuzRcTLkZSnFqBMgZ+kC4hsbLsiBHkbaEur+VqdZ/zihQdDptmV0fW2kYtR9/jxfRsQ/vcLLs9a+fnhmCdruhzoKMJ8NwFDxm9wieQMAyGu0x6mEFq0tCGyn1UsgVMLfCoQOEVSQKB2QZ0XN8Wq3NL1vCWD02qGs/8Klxp8HrslXMOT5uqdddMsUHRA1UcBbKfkmONNy27X7pkXb1owT0d3Tulet3YBaYRGYXNsbECf/MAsV8GUGsbDnXWn4kzwL9B9Sep53jr4QqNRF1o762k8E2ZMRbwF87e2HxE3TEKHDENm813l7p1g3aBu4pakZRVScpNZxJEJ+oLP8nMV+RskwAFygor/VGI/db4o7Jz+boEyq/5gmTU8A1VSqEYwx9GME6I4cE3y6P9TyHAc/6Ls="
|
||||
file: 816-tcc.zip
|
||||
skip_cleanup: true
|
||||
on:
|
||||
tags: true
|
579
816-opt.py
Normal file
579
816-opt.py
Normal file
@ -0,0 +1,579 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
#import hotshot
|
||||
#prof = hotshot.Profile('816-opt.prof')
|
||||
#prof.start()
|
||||
|
||||
verbose = True
|
||||
if os.getenv('OPT816_QUIET'): verbose = False
|
||||
|
||||
# open the assembler file and put lines in array text
|
||||
text_raw = open(sys.argv[1],'r').readlines()
|
||||
text = []
|
||||
for l in text_raw:
|
||||
if not l.startswith(';'): text += [l.strip()]
|
||||
|
||||
# find .bss section symbols
|
||||
bss = []
|
||||
bsson = False
|
||||
for l in text:
|
||||
if l == '.ramsection ".bss" bank $7e slot 2':
|
||||
bsson = True
|
||||
continue
|
||||
if l == '.ends':
|
||||
bsson = False
|
||||
if bsson:
|
||||
bss += [l.split(' ')[0]]
|
||||
#print 'bss',bss
|
||||
|
||||
# checks if the line alters the control flow
|
||||
def is_control(line):
|
||||
if len(line) > 0 and line[0] in 'jb+-' or line.endswith(':'): return True
|
||||
return False
|
||||
|
||||
def changes_accu(line):
|
||||
if (line[2] == 'a' and not line[:3] in ['pha','sta']) or (len(line) == 5 and line.endswith(' a')): return True
|
||||
else: return False
|
||||
|
||||
totalopt = 0 # total number of optimizations performed
|
||||
opted = -1 # have we optimized in this pass?
|
||||
opass = 0 # optimization pass counter
|
||||
storetopseudo = re.compile('st([axyz]).b tcc__([rf][0-9]*h?)$')
|
||||
storexytopseudo = re.compile('st([xy]).b tcc__([rf][0-9]*h?)$')
|
||||
storeatopseudo = re.compile('sta.b tcc__([rf][0-9]*h?)$')
|
||||
while opted:
|
||||
opass += 1
|
||||
if verbose: sys.stderr.write('optimization pass ' + str(opass) + ': ')
|
||||
opted = 0 # no optimizations performed
|
||||
text_opt = [] # optimized code array, will be filled in during this pass
|
||||
i = 0
|
||||
while i < len(text):
|
||||
if text[i].startswith('st'):
|
||||
# stores (accu/x/y/zero) to pseudo-registers
|
||||
r = storetopseudo.match(text[i])
|
||||
if r:
|
||||
# eliminate redundant stores
|
||||
doopt = False
|
||||
for j in range(i+1, min(len(text),i+30)):
|
||||
r1 = re.match('st([axyz]).b tcc__' + r.groups()[1] + '$', text[j])
|
||||
if r1:
|
||||
doopt = True # another store to the same pregister
|
||||
break
|
||||
if text[j].startswith('jsr.l ') and not text[j].startswith('jsr.l tcc__'):
|
||||
doopt = True # before function call (will be clobbered anyway)
|
||||
break
|
||||
# cases in which we don't pursue optimization further
|
||||
if is_control(text[j]) or ('tcc__' + r.groups()[1]) in text[j]: break # branch or other use of the preg
|
||||
if r.groups()[1].endswith('h') and ('[tcc__' + r.groups()[1].rstrip('h')) in text[j]: break # use as a pointer
|
||||
if doopt:
|
||||
i += 1 # skip redundant store
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# stores (x/y) to pseudo-registers
|
||||
r = storexytopseudo.match(text[i])
|
||||
if r:
|
||||
# store hwreg to preg, push preg, function call -> push hwreg, function call
|
||||
if text[i+1] == 'pei (tcc__' + r.groups()[1] + ')' and text[i+2].startswith('jsr.l '):
|
||||
text_opt += ['ph' + r.groups()[0]]
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
# store hwreg to preg, push preg -> store hwreg to preg, push hwreg (shorter)
|
||||
if text[i+1] == 'pei (tcc__' + r.groups()[1] + ')':
|
||||
text_opt += [text[i]]
|
||||
text_opt += ['ph' + r.groups()[0]]
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
# store hwreg to preg, load hwreg from preg -> store hwreg to preg, transfer hwreg/hwreg (shorter)
|
||||
if text[i+1] == 'lda.b tcc__' + r.groups()[1] or text[i+1] == 'lda.b tcc__' + r.groups()[1] + " ; DON'T OPTIMIZE":
|
||||
text_opt += [text[i]]
|
||||
text_opt += ['t' + r.groups()[0] + 'a'] # FIXME: shouldn't this be marked as DON'T OPTIMIZE again?
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# stores (accu only) to pseudo-registers
|
||||
r = storeatopseudo.match(text[i])
|
||||
if r:
|
||||
#sys.stderr.write('looking for lda.b tcc__r' + r.groups()[0] + ' in ' + text[i+1] + '\n')
|
||||
# store preg followed by load preg
|
||||
if text[i+1] == 'lda.b tcc__' + r.groups()[0]:
|
||||
#sys.stderr.write('found!\n')
|
||||
text_opt += [text[i]] # keep store
|
||||
i += 2 # omit load
|
||||
opted += 1
|
||||
continue
|
||||
# store preg followed by load preg with ldx/ldy in between
|
||||
if (text[i+1].startswith('ldx') or text[i+1].startswith('ldy')) and text[i+2] == 'lda.b tcc__' + r.groups()[0]:
|
||||
text_opt += [text[i]] # keep store
|
||||
text_opt += [text[i+1]]
|
||||
i += 3 # omit load
|
||||
opted += 1
|
||||
continue
|
||||
# store accu to preg, push preg, function call -> push accu, function call
|
||||
if text[i+1] == 'pei (tcc__' + r.groups()[0] + ')' and text[i+2].startswith('jsr.l '):
|
||||
text_opt += ['pha']
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
# store accu to preg, push preg -> store accu to preg, push accu (shorter)
|
||||
if text[i+1] == 'pei (tcc__' + r.groups()[0] + ')':
|
||||
text_opt += [text[i]]
|
||||
text_opt += ['pha']
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
# store accu to preg1, push preg2, push preg1 -> store accu to preg1, push preg2, push accu
|
||||
elif text[i+1].startswith('pei ') and text[i+2] == 'pei (tcc__' + r.groups()[0] + ')':
|
||||
text_opt += [text[i+1]]
|
||||
text_opt += [text[i]]
|
||||
text_opt += ['pha']
|
||||
i += 3
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# convert incs/decs on pregs incs/decs on hwregs
|
||||
cont = False
|
||||
for crem in 'inc','dec':
|
||||
if text[i+1] == crem + '.b tcc__' + r.groups()[0]:
|
||||
# store to preg followed by crement on preg
|
||||
if text[i+2] == crem + '.b tcc__' + r.groups()[0] and text[i+3].startswith('lda'):
|
||||
# store to preg followed by two crements on preg
|
||||
# increment the accu first, then store it to preg
|
||||
text_opt += [crem + ' a',crem + ' a','sta.b tcc__' + r.groups()[0]]
|
||||
# a subsequent load can be omitted (the right value is already in the accu)
|
||||
if text[i+3] == 'lda.b tcc__' + r.groups()[0]: i += 4
|
||||
else: i += 3
|
||||
opted += 1
|
||||
cont = True
|
||||
break
|
||||
elif text[i+2].startswith('lda'): #text[i+2] == 'lda.b tcc__' + r.groups()[0]:
|
||||
# same thing with only one crement (FIXME: there should be a more clever way to do this...)
|
||||
text_opt += [crem + ' a','sta.b tcc__' + r.groups()[0]]
|
||||
if text[i+2] == 'lda.b tcc__' + r.groups()[0]: i += 3
|
||||
else: i += 2
|
||||
opted += 1
|
||||
cont = True
|
||||
break
|
||||
if cont: continue
|
||||
|
||||
r1 = re.match('lda.b tcc__([rf][0-9]*)',text[i+1])
|
||||
if r1:
|
||||
#sys.stderr.write('t '+text[i+2][:3]+'\n')
|
||||
if text[i+2][:3] in ['and','ora']:
|
||||
# store to preg1, load from preg2, and/or preg1 -> store to preg1, and/or preg2
|
||||
#sys.stderr.write('found in line ' + str(i) + '!\n')
|
||||
if text[i+2][3:] == '.b tcc__' + r.groups()[0]:
|
||||
text_opt += [text[i]] # store
|
||||
text_opt += [text[i+2][:3] + '.b tcc__' + r1.groups()[0]]
|
||||
i += 3
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# store to preg, switch to 8 bits, load from preg => skip the load
|
||||
if text[i+1] == 'sep #$20' and text[i+2] == 'lda.b tcc__' + r.groups()[0]:
|
||||
text_opt += [text[i]]
|
||||
text_opt += [text[i+1]]
|
||||
i += 3 # skip load
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# two stores to preg without control flow or other uses of preg => skip first store
|
||||
if not is_control(text[i+1]) and not ('tcc__' + r.groups()[0]) in text[i+1]:
|
||||
if text[i+2] == text[i]:
|
||||
text_opt += [text[i+1]]
|
||||
text_opt += [text[i+2]]
|
||||
i += 3 # skip first store
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# store hwreg to preg, load hwreg from preg -> store hwreg to preg, transfer hwreg/hwreg (shorter)
|
||||
r1 = re.match('ld([xy]).b tcc__' + r.groups()[0], text[i+1])
|
||||
if r1:
|
||||
text_opt += [text[i]]
|
||||
text_opt += ['ta' + r1.groups()[0]]
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# store accu to preg then load accu from preg, with something in-between that does not alter
|
||||
# control flow or touch accu or preg => skip load
|
||||
if not (is_control(text[i+1]) or changes_accu(text[i+1]) or 'tcc__' + r.groups()[0] in text[i+1]):
|
||||
if text[i+2] == 'lda.b tcc__' + r.groups()[0]:
|
||||
text_opt += [text[i]]
|
||||
text_opt += [text[i+1]]
|
||||
i += 3 # skip load
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# store preg1, clc, load preg2, add preg1 -> store preg1, clc, add preg2
|
||||
if text[i+1] == 'clc':
|
||||
r1 = re.match('lda.b tcc__(r[0-9]*)', text[i+2])
|
||||
if r1 and text[i+3] == 'adc.b tcc__' + r.groups()[0]:
|
||||
text_opt += [text[i]]
|
||||
text_opt += [text[i+1]]
|
||||
text_opt += ['adc.b tcc__' + r1.groups()[0]]
|
||||
i += 4 # skip load
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# store accu to preg, asl preg => asl accu, store accu to preg
|
||||
# FIXME: is this safe? can we rely on code not making assumptions about the contents of the accu
|
||||
# after the shift?
|
||||
if text[i+1] == 'asl.b tcc__' + r.groups()[0]:
|
||||
text_opt += ['asl a']
|
||||
text_opt += [text[i]]
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
r = re.match('sta (.*),s$', text[i])
|
||||
if r:
|
||||
if text[i+1] == 'lda ' + r.groups()[0] + ',s':
|
||||
text_opt += [text[i]]
|
||||
i += 2 # omit load
|
||||
opted += 1
|
||||
continue
|
||||
# end startswith('st')
|
||||
|
||||
if text[i].startswith('ld'):
|
||||
r = re.match('ldx #0', text[i])
|
||||
if r:
|
||||
r1 = re.match('lda.l (.*),x$', text[i+1])
|
||||
if r1 and not text[i+3].endswith(',x'):
|
||||
text_opt += ['lda.l ' + r1.groups()[0]]
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
elif r1:
|
||||
text_opt += ['lda.l ' + r1.groups()[0]]
|
||||
text_opt += [text[i+2]]
|
||||
text_opt += [text[i+3].replace(',x','')]
|
||||
i += 4
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
if text[i].startswith('lda.w #') and \
|
||||
text[i+1] == 'sta.b tcc__r9' and \
|
||||
text[i+2].startswith('lda.w #') and \
|
||||
text[i+3] == 'sta.b tcc__r9h' and \
|
||||
text[i+4] == 'sep #$20' and \
|
||||
text[i+5].startswith('lda.b ') and \
|
||||
text[i+6] == 'sta.b [tcc__r9]' and \
|
||||
text[i+7] == 'rep #$20':
|
||||
text_opt += ['sep #$20']
|
||||
text_opt += [text[i+5]]
|
||||
text_opt += ['sta.l ' + str(int(text[i+2][7:]) * 65536 + int(text[i][7:]))]
|
||||
text_opt += ['rep #$20']
|
||||
i += 8
|
||||
opted += 1
|
||||
#sys.stderr.write('7')
|
||||
continue
|
||||
|
||||
if text[i] == 'lda.w #0':
|
||||
if text[i+1].startswith('sta.b ') and text[i+2].startswith('lda'):
|
||||
text_opt += [text[i+1].replace('sta.','stz.')]
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
elif text[i].startswith('lda.w #'):
|
||||
if text[i+1] == 'sep #$20' and text[i+2].startswith('sta ') and text[i+3] == 'rep #$20' and text[i+4].startswith('lda'):
|
||||
text_opt += ['sep #$20', text[i].replace('lda.w', 'lda.b'), text[i+2], text[i+3]]
|
||||
i += 4
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
if text[i].startswith('lda.b') and not is_control(text[i+1]) and not 'a' in text[i+1] and text[i+2].startswith('lda.b'):
|
||||
text_opt += [text[i+1],text[i+2]]
|
||||
i += 3
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# don't write preg high back to stack if it hasn't been updated
|
||||
if text[i+1].endswith('h') and text[i+1].startswith('sta.b tcc__r') and text[i].startswith('lda ') and text[i].endswith(',s'):
|
||||
#sys.stderr.write('checking lines\n')
|
||||
#sys.stderr.write(text[i] + '\n' + text[i+1] + '\n')
|
||||
local = text[i][4:]
|
||||
reg = text[i+1][6:]
|
||||
# lda stack ; store high preg ; ... ; load high preg ; sta stack
|
||||
j = i + 2
|
||||
while j < len(text) - 2 and not is_control(text[j]) and not reg in text[j]:
|
||||
j += 1
|
||||
if text[j] == 'lda.b ' + reg and text[j+1] == 'sta ' + local:
|
||||
while i < j:
|
||||
text_opt += [text[i]]
|
||||
i += 1
|
||||
i += 2 # skip load high preg ; sta stack
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
# reorder copying of 32-bit value to preg if it looks as if that could
|
||||
# allow further optimization
|
||||
# looking for
|
||||
# lda something
|
||||
# sta.b tcc_rX
|
||||
# lda something
|
||||
# sta.b tcc_rYh
|
||||
# ...tcc_rX...
|
||||
if text[i].startswith('lda') and text[i+1].startswith('sta.b tcc__r'):
|
||||
reg = text[i+1][6:]
|
||||
if not reg.endswith('h') and \
|
||||
text[i+2].startswith('lda') and not text[i+2].endswith(reg) and \
|
||||
text[i+3].startswith('sta.b tcc__r') and text[i+3].endswith('h') and \
|
||||
text[i+4].endswith(reg):
|
||||
text_opt += [text[i+2], text[i+3]]
|
||||
text_opt += [text[i], text[i+1]]
|
||||
i += 4
|
||||
# this is not an optimization per se, so we don't count it
|
||||
continue
|
||||
|
||||
# compare optimizations inspired by optimore
|
||||
# These opts simplify compare operations, which are monstrous because
|
||||
# they have to take the long long case into account.
|
||||
# We try to detect those cases by checking if a tya follows the
|
||||
# comparison (not sure if this is reliable, but it passes the test suite)
|
||||
if text[i] == 'ldx #1' and \
|
||||
text[i+1].startswith('lda.b tcc__') and \
|
||||
text[i+2] == 'sec' and \
|
||||
text[i+3].startswith('sbc #') and \
|
||||
text[i+4] == 'tay' and \
|
||||
text[i+5] == 'beq +' and \
|
||||
text[i+6] == 'dex' and \
|
||||
text[i+7] == '+' and \
|
||||
text[i+8].startswith('stx.b tcc__') and \
|
||||
text[i+9] == 'txa' and \
|
||||
text[i+10] == 'bne +' and \
|
||||
text[i+11].startswith('brl ') and \
|
||||
text[i+12] == '+' and \
|
||||
text[i+13] != 'tya':
|
||||
text_opt += [text[i+1]]
|
||||
text_opt += ['cmp #' + text[i+3][5:]]
|
||||
text_opt += [text[i+5]]
|
||||
text_opt += [text[i+11]] # brl
|
||||
text_opt += [text[i+12]] # +
|
||||
i += 13
|
||||
opted += 1
|
||||
#sys.stderr.write('1')
|
||||
continue
|
||||
|
||||
if text[i] == 'ldx #1' and \
|
||||
text[i+1] == 'sec' and \
|
||||
text[i+2].startswith('sbc #') and \
|
||||
text[i+3] == 'tay' and \
|
||||
text[i+4] == 'beq +' and \
|
||||
text[i+5] == 'dex' and \
|
||||
text[i+6] == '+' and \
|
||||
text[i+7].startswith('stx.b tcc__') and \
|
||||
text[i+8] == 'txa' and \
|
||||
text[i+9] == 'bne +' and \
|
||||
text[i+10].startswith('brl ') and \
|
||||
text[i+11] == '+' and \
|
||||
text[i+12] != 'tya':
|
||||
text_opt += ['cmp #' + text[i+2][5:]]
|
||||
text_opt += [text[i+4]]
|
||||
text_opt += [text[i+10]] # brl
|
||||
text_opt += [text[i+11]] # +
|
||||
i += 12
|
||||
opted += 1
|
||||
#sys.stderr.write('2')
|
||||
continue
|
||||
|
||||
if text[i] == 'ldx #1' and \
|
||||
text[i+1].startswith('lda.b tcc__r') and \
|
||||
text[i+2] == 'sec' and \
|
||||
text[i+3].startswith('sbc.b tcc__r') and \
|
||||
text[i+4] == 'tay' and \
|
||||
text[i+5] == 'beq +' and \
|
||||
text[i+6] == 'bcs ++' and \
|
||||
text[i+7] == '+ dex' and \
|
||||
text[i+8] == '++' and \
|
||||
text[i+9].startswith('stx.b tcc__r') and \
|
||||
text[i+10] == 'txa' and \
|
||||
text[i+11] == 'bne +' and \
|
||||
text[i+12].startswith('brl ') and \
|
||||
text[i+13] == '+' and \
|
||||
text[i+14] != 'tya':
|
||||
text_opt += [text[i+1]]
|
||||
text_opt += ['cmp.b ' + text[i+3][6:]]
|
||||
text_opt += [text[i+5]]
|
||||
text_opt += ['bcc +']
|
||||
text_opt += ['brl ++']
|
||||
text_opt += ['+']
|
||||
text_opt += [text[i+12]]
|
||||
text_opt += ['++']
|
||||
i += 14
|
||||
opted += 1
|
||||
#sys.stderr.write('3')
|
||||
continue
|
||||
|
||||
if text[i] == 'ldx #1' and \
|
||||
text[i+1] == 'sec' and \
|
||||
text[i+2].startswith('sbc.w #') and \
|
||||
text[i+3] == 'tay' and \
|
||||
text[i+4] == 'bvc +' and \
|
||||
text[i+5] == 'eor #$8000' and \
|
||||
text[i+6] == '+' and \
|
||||
text[i+7] == 'bmi +++' and \
|
||||
text[i+8] == '++' and \
|
||||
text[i+9] == 'dex' and \
|
||||
text[i+10] == '+++' and \
|
||||
text[i+11].startswith('stx.b tcc__r') and \
|
||||
text[i+12] == 'txa' and \
|
||||
text[i+13] == 'bne +' and \
|
||||
text[i+14].startswith('brl ') and \
|
||||
text[i+15] == '+' and \
|
||||
text[i+16] != 'tya':
|
||||
text_opt += [text[i+1]]
|
||||
text_opt += [text[i+2]]
|
||||
text_opt += [text[i+4]]
|
||||
text_opt += ['eor #$8000']
|
||||
text_opt += ['+']
|
||||
text_opt += ['bmi +']
|
||||
text_opt += [text[i+14]]
|
||||
text_opt += ['+']
|
||||
i += 16
|
||||
opted += 1
|
||||
#sys.stderr.write('4')
|
||||
continue
|
||||
|
||||
if text[i] == 'ldx #1' and \
|
||||
text[i+1].startswith('lda.b tcc__r') and \
|
||||
text[i+2] == 'sec' and \
|
||||
text[i+3].startswith('sbc.b tcc__r') and \
|
||||
text[i+4] == 'tay' and \
|
||||
text[i+5] == 'bvc +' and \
|
||||
text[i+6] == 'eor #$8000' and \
|
||||
text[i+7] == '+' and \
|
||||
text[i+8] == 'bmi +++' and \
|
||||
text[i+9] == '++' and \
|
||||
text[i+10] == 'dex' and \
|
||||
text[i+11] == '+++' and \
|
||||
text[i+12].startswith('stx.b tcc__r') and \
|
||||
text[i+13] == 'txa' and \
|
||||
text[i+14] == 'bne +' and \
|
||||
text[i+15].startswith('brl ') and \
|
||||
text[i+16] == '+' and \
|
||||
text[i+17] != 'tya':
|
||||
text_opt += [text[i+1]]
|
||||
text_opt += [text[i+2]]
|
||||
text_opt += [text[i+3]]
|
||||
text_opt += [text[i+5]]
|
||||
text_opt += [text[i+6]]
|
||||
text_opt += ['+']
|
||||
text_opt += ['bmi +']
|
||||
text_opt += [text[i+15]]
|
||||
text_opt += ['+']
|
||||
i += 17
|
||||
opted += 1
|
||||
#sys.stderr.write('5')
|
||||
continue
|
||||
|
||||
if text[i] == 'ldx #1' and \
|
||||
text[i+1] == 'sec' and \
|
||||
text[i+2].startswith('sbc.b tcc__r') and \
|
||||
text[i+3] == 'tay' and \
|
||||
text[i+4] == 'bvc +' and \
|
||||
text[i+5] == 'eor #$8000' and \
|
||||
text[i+6] == '+' and \
|
||||
text[i+7] == 'bmi +++' and \
|
||||
text[i+8] == '++' and \
|
||||
text[i+9] == 'dex' and \
|
||||
text[i+10] == '+++' and \
|
||||
text[i+11].startswith('stx.b tcc__r') and \
|
||||
text[i+12] == 'txa' and \
|
||||
text[i+13] == 'bne +' and \
|
||||
text[i+14].startswith('brl ') and \
|
||||
text[i+15] == '+' and \
|
||||
text[i+16] != 'tya':
|
||||
text_opt += [text[i+1]]
|
||||
text_opt += [text[i+2]]
|
||||
text_opt += [text[i+4]]
|
||||
text_opt += [text[i+5]]
|
||||
text_opt += ['+']
|
||||
text_opt += ['bmi +']
|
||||
text_opt += [text[i+14]]
|
||||
text_opt += ['+']
|
||||
i += 16
|
||||
opted += 1
|
||||
#sys.stderr.write('6')
|
||||
continue
|
||||
|
||||
# end startswith('ld')
|
||||
|
||||
if text[i] == 'rep #$20' and text[i+1] == 'sep #$20':
|
||||
i += 2
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
if text[i] == 'sep #$20' and text[i+1].startswith('lda #') and text[i+2] == 'pha' and text[i+3].startswith('lda #') and text[i+4] == 'pha':
|
||||
text_opt += ['pea.w (' + text[i+1].split('#')[1] + ' * 256 + ' + text[i+3].split('#')[1] + ')']
|
||||
text_opt += [text[i]]
|
||||
i += 5
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
r = re.match('adc #(.*)$',text[i])
|
||||
if r:
|
||||
r1 = re.match('sta.b (tcc__[fr][0-9]*)$', text[i+1])
|
||||
if r1:
|
||||
if text[i+2] == 'inc.b ' + r1.groups()[0] and text[i+3] == 'inc.b ' + r1.groups()[0]:
|
||||
text_opt += ['adc #' + r.groups()[0] + ' + 2']
|
||||
text_opt += [text[i+1]]
|
||||
i += 4
|
||||
opted += 1
|
||||
continue
|
||||
|
||||
if text[i][:6] in ['lda.l ','sta.l ']:
|
||||
cont = False
|
||||
for b in bss:
|
||||
if text[i][2:].startswith('a.l ' + b + ' '):
|
||||
text_opt += [text[i].replace('lda.l','lda.w').replace('sta.l','sta.w')]
|
||||
i += 1
|
||||
opted += 1
|
||||
cont = True
|
||||
break
|
||||
if cont: continue
|
||||
|
||||
if text[i].startswith('jmp.w ') or text[i].startswith('bra __'):
|
||||
j = i + 1
|
||||
cont = False
|
||||
while j < len(text) and text[j].endswith(':'):
|
||||
if text[i].endswith(text[j][:-1]):
|
||||
# redundant branch, discard it
|
||||
i += 1
|
||||
opted += 1
|
||||
cont = True
|
||||
break
|
||||
j += 1
|
||||
if cont: continue
|
||||
|
||||
if text[i].startswith('jmp.w '):
|
||||
# worst case is a 4-byte instruction, so if the jump target is closer
|
||||
# than 32 instructions, we can safely substitute a branch
|
||||
label = text[i][6:] + ':'
|
||||
cont = False
|
||||
for lpos in range(max(0, i - 32), min(len(text), i + 32)):
|
||||
if text[lpos] == label:
|
||||
text_opt += [text[i].replace('jmp.w','bra')]
|
||||
i += 1
|
||||
opted += 1
|
||||
cont = True
|
||||
break
|
||||
if cont: continue
|
||||
|
||||
text_opt += [text[i]]
|
||||
i += 1
|
||||
text = text_opt
|
||||
if verbose: sys.stderr.write(str(opted) + ' optimizations performed\n')
|
||||
totalopt += opted
|
||||
|
||||
for l in text_opt: print l
|
||||
if verbose: sys.stderr.write(str(totalopt) + ' optimizations performed in total\n')
|
||||
|
||||
#prof.stop()
|
504
COPYING
Normal file
504
COPYING
Normal file
@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
281
Changelog
Normal file
281
Changelog
Normal file
@ -0,0 +1,281 @@
|
||||
version 0.9.23:
|
||||
|
||||
- initial PE executable format for windows version (grischka)
|
||||
- '#pragma pack' support (grischka)
|
||||
- '#include_next' support (Bernhard Fischer)
|
||||
- ignore '-pipe' option
|
||||
- added -f[no-]leading-underscore
|
||||
- preprocessor function macro parsing fix (grischka)
|
||||
|
||||
version 0.9.22:
|
||||
|
||||
- simple memory optimisations: kernel compilation is 30% faster
|
||||
- linker symbol definitions fixes
|
||||
- gcc 3.4 fixes
|
||||
- fixed value stack full error
|
||||
- 'packed' attribute support for variables and structure fields
|
||||
- ignore 'const' and 'volatile' in function prototypes
|
||||
- allow '_Bool' in bit fields
|
||||
|
||||
version 0.9.21:
|
||||
|
||||
- ARM target support (Daniel Glöckner)
|
||||
- added '-funsigned-char, '-fsigned-char' and
|
||||
'-Wimplicit-function-declaration'
|
||||
- fixed assignment of const struct in struct
|
||||
- line comment fix (reported by Bertram Felgenhauer)
|
||||
- initial TMS320C67xx target support (TK)
|
||||
- win32 configure
|
||||
- regparm() attribute
|
||||
- many built-in assembler fixes
|
||||
- added '.org', '.fill' and '.previous' assembler directives
|
||||
- '-fno-common' option
|
||||
- '-Ttext' linker option
|
||||
- section alignment fixes
|
||||
- bit fields fixes
|
||||
- do not generate code for unused inline functions
|
||||
- '-oformat' linker option.
|
||||
- added 'binary' output format.
|
||||
|
||||
version 0.9.20:
|
||||
|
||||
- added '-w' option
|
||||
- added '.gnu.linkonce' ELF sections support
|
||||
- fixed libc linking when running in memory (avoid 'stat' function
|
||||
errors).
|
||||
- extended '-run' option to be able to give several arguments to a C
|
||||
script.
|
||||
|
||||
version 0.9.19:
|
||||
|
||||
- "alacarte" linking (Dave Long)
|
||||
- simpler function call
|
||||
- more strict type checks
|
||||
- added 'const' and 'volatile' support and associated warnings
|
||||
- added -Werror, -Wunsupported, -Wwrite-strings, -Wall.
|
||||
- added __builtin_types_compatible_p() and __builtin_constant_p()
|
||||
- chars support in assembler (Dave Long)
|
||||
- .string, .globl, .section, .text, .data and .bss asm directive
|
||||
support (Dave Long)
|
||||
- man page generated from tcc-doc.texi
|
||||
- fixed macro argument substitution
|
||||
- fixed zero argument macro parsing
|
||||
- changed license to LGPL
|
||||
- added -rdynamic option support
|
||||
|
||||
version 0.9.18:
|
||||
|
||||
- header fix (time.h)
|
||||
- fixed inline asm without operand case
|
||||
- fixed 'default:' or 'case x:' with '}' after (incorrect C construct accepted
|
||||
by gcc)
|
||||
- added 'A' inline asm constraint.
|
||||
|
||||
version 0.9.17:
|
||||
|
||||
- PLT generation fix
|
||||
- tcc doc fixes (Peter Lund)
|
||||
- struct parse fix (signaled by Pedro A. Aranda Gutierrez)
|
||||
- better _Bool lvalue support (signaled by Alex Measday)
|
||||
- function parameters must be converted to pointers (signaled by Neil Brown)
|
||||
- sanitized string and character constant parsing
|
||||
- fixed comment parse (signaled by Damian M Gryski)
|
||||
- fixed macro function bug (signaled by Philippe Ribet)
|
||||
- added configure (initial patch by Mitchell N Charity)
|
||||
- added '-run' and '-v' options (initial patch by vlindos)
|
||||
- added real date report in __DATE__ and __TIME__ macros
|
||||
|
||||
version 0.9.16:
|
||||
|
||||
- added assembler language support
|
||||
- added GCC inline asm() support
|
||||
- fixed multiple variable definitions : uninitialized variables are
|
||||
created as COMMON symbols.
|
||||
- optimized macro processing
|
||||
- added GCC statement expressions support
|
||||
- added GCC local labels support
|
||||
- fixed array declaration in old style function parameters
|
||||
- support casts in static structure initializations
|
||||
- added various __xxx[__] keywords for GCC compatibility
|
||||
- ignore __extension__ GCC in an expression or in a type (still not perfect)
|
||||
- added '? :' GCC extension support
|
||||
|
||||
version 0.9.15:
|
||||
|
||||
- compilation fixes for glibc 2.2, gcc 2.95.3 and gcc 3.2.
|
||||
- FreeBSD compile fixes. Makefile patches still missing (Carl Drougge).
|
||||
- fixed file type guessing if '.' is in the path.
|
||||
- fixed tcc_compile_string()
|
||||
- add a dummy page in ELF files to fix RX/RW accesses (pageexec at
|
||||
freemail dot hu).
|
||||
|
||||
version 0.9.14:
|
||||
|
||||
- added #warning. error message if invalid preprocessing directive.
|
||||
- added CType structure to ease typing (faster parse).
|
||||
- suppressed secondary hash tables (faster parse).
|
||||
- rewrote parser by optimizing common cases (faster parse).
|
||||
- fixed signed long long comparisons.
|
||||
- fixed 'int a(), b();' declaration case.
|
||||
- fixed structure init without '{}'.
|
||||
- correct alignment support in structures.
|
||||
- empty structures support.
|
||||
- gcc testsuite now supported.
|
||||
- output only warning if implicit integer/pointer conversions.
|
||||
- added static bitfield init.
|
||||
|
||||
version 0.9.13:
|
||||
|
||||
- correct preprocessing token pasting (## operator) in all cases (added
|
||||
preprocessing number token).
|
||||
- fixed long long register spill.
|
||||
- fixed signed long long '>>'.
|
||||
- removed memory leaks.
|
||||
- better error handling : processing can continue on link errors. A
|
||||
custom callback can be added to display error messages. Most
|
||||
errors do not call exit() now.
|
||||
- ignore -O, -W, -m and -f options
|
||||
- added old style function declarations
|
||||
- added GCC __alignof__ support.
|
||||
- added GCC typeof support.
|
||||
- added GCC computed gotos support.
|
||||
- added stack backtrace in runtime error message. Improved runtime
|
||||
error position display.
|
||||
|
||||
version 0.9.12:
|
||||
|
||||
- more fixes for || and && handling.
|
||||
- improved '? :' type handling.
|
||||
- fixed bound checking generation with structures
|
||||
- force '#endif' to be in same file as matching '#if'
|
||||
- #include file optimization with '#ifndef #endif' construct detection
|
||||
- macro handling optimization
|
||||
- added tcc_relocate() and tcc_get_symbol() in libtcc.
|
||||
|
||||
version 0.9.11:
|
||||
|
||||
- stdarg.h fix for double type (thanks to Philippe Ribet).
|
||||
- correct white space characters and added MSDOS newline support.
|
||||
- fixed invalid implicit function call type declaration.
|
||||
- special macros such as __LINE__ are defined if tested with defined().
|
||||
- fixed '!' operator with relocated address.
|
||||
- added symbol + offset relocation (fixes some static variable initializers)
|
||||
- '-l' option can be specified anywhere. '-c' option yields default
|
||||
output name. added '-r' option for relocatable output.
|
||||
- fixed '\nnn' octal parsing.
|
||||
- fixed local extern variables declarations.
|
||||
|
||||
version 0.9.10:
|
||||
|
||||
- fixed lvalue type when saved in local stack.
|
||||
- fixed '#include' syntax when using macros.
|
||||
- fixed '#line' bug.
|
||||
- removed size limit on strings. Unified string constants handling
|
||||
with variable declarations.
|
||||
- added correct support for '\xX' in wchar_t strings.
|
||||
- added support for bound checking in generated executables
|
||||
- fixed -I include order.
|
||||
- fixed incorrect function displayed in runtime error.
|
||||
|
||||
version 0.9.9:
|
||||
|
||||
- fixed preprocessor expression parsing for #if/#elif.
|
||||
- relocated debug info (.stab section).
|
||||
- relocated bounds info (.bounds section).
|
||||
- fixed cast to char of char constants ('\377' is -1 instead of 255)
|
||||
- fixed implicit cast for unary plus.
|
||||
- strings and '__func__' have now 'char[]' type instead of 'char *'
|
||||
(fixes sizeof() return value).
|
||||
- added __start_xxx and __stop_xxx symbols in linker.
|
||||
- better DLL creation support (option -shared begins to work).
|
||||
- ELF sections and hash tables are resized dynamically.
|
||||
- executables and DLLs are stripped by default.
|
||||
|
||||
version 0.9.8:
|
||||
|
||||
- First version of full ELF linking support (generate objects, static
|
||||
executable, dynamic executable, dynamic libraries). Dynamic library
|
||||
support is not finished (need PIC support in compiler and some
|
||||
patches in symbol exporting).
|
||||
- First version of ELF loader for object (.o) and archive (.a) files.
|
||||
- Support of simple GNU ld scripts (GROUP and FILE commands)
|
||||
- Separated runtime library and bound check code from TCC (smaller
|
||||
compiler core).
|
||||
- fixed register reload in float compare.
|
||||
- fixed implicit char/short to int casting.
|
||||
- allow array type for address of ('&') operator.
|
||||
- fixed unused || or && result.
|
||||
- added GCC style variadic macro support.
|
||||
- optimized bound checking code for array access.
|
||||
- tcc includes are now in $(prefix)/lib/tcc/include.
|
||||
- more command line options - more consistent handling of multiple
|
||||
input files.
|
||||
- added tcc man page (thanks to Cyril Bouthors).
|
||||
- uClibc Makefile update
|
||||
- converted documentation to texinfo format.
|
||||
- added developper's guide in documentation.
|
||||
|
||||
version 0.9.7:
|
||||
|
||||
- added library API for easy dynamic compilation (see libtcc.h - first
|
||||
draft).
|
||||
- fixed long long register spill bug.
|
||||
- fixed '? :' register spill bug.
|
||||
|
||||
version 0.9.6:
|
||||
|
||||
- added floating point constant propagation (fixes negative floating
|
||||
point constants bug).
|
||||
|
||||
version 0.9.5:
|
||||
|
||||
- uClibc patches (submitted by Alfonso Martone).
|
||||
- error reporting fix
|
||||
- added CONFIG_TCC_BCHECK to get smaller code if needed.
|
||||
|
||||
version 0.9.4:
|
||||
|
||||
- windows port (currently cannot use -g, -b and dll functions).
|
||||
- faster and simpler I/O handling.
|
||||
- '-D' option works in all cases.
|
||||
- preprocessor fixes (#elif and empty macro args)
|
||||
- floating point fixes
|
||||
- first code for CIL generation (does not work yet)
|
||||
|
||||
version 0.9.3:
|
||||
|
||||
- better and smaller code generator.
|
||||
- full ISOC99 64 bit 'long long' support.
|
||||
- full 32 bit 'float', 64 bit 'double' and 96 bit 'long double' support.
|
||||
- added '-U' option.
|
||||
- added assembly sections support.
|
||||
- even faster startup time by mmaping sections instead of mallocing them.
|
||||
- added GNUC __attribute__ keyword support (currently supports
|
||||
'section' and 'aligned' attributes).
|
||||
- added ELF file output (only usable for debugging now)
|
||||
- added debug symbol generation (STAB format).
|
||||
- added integrated runtime error analysis ('-g' option: print clear
|
||||
run time error messages instead of "Segmentation fault").
|
||||
- added first version of tiny memory and bound checker ('-b' option).
|
||||
|
||||
version 0.9.2:
|
||||
|
||||
- even faster parsing.
|
||||
- various syntax parsing fixes.
|
||||
- fixed external relocation handling for variables or functions pointers.
|
||||
- better function pointers type handling.
|
||||
- can compile multiple files (-i option).
|
||||
- ANSI C bit fields are supported.
|
||||
- beginning of float/double/long double support.
|
||||
- beginning of long long support.
|
||||
|
||||
version 0.9.1:
|
||||
|
||||
- full ISOC99 initializers handling.
|
||||
- compound literals.
|
||||
- structures handle in assignments and as function param or return value.
|
||||
- wide chars and strings.
|
||||
- macro bug fix
|
||||
|
||||
version 0.9:
|
||||
- initial version.
|
268
Makefile
Normal file
268
Makefile
Normal file
@ -0,0 +1,268 @@
|
||||
#
|
||||
# Tiny C Compiler Makefile
|
||||
#
|
||||
include config.mak
|
||||
|
||||
#CFLAGS=-pg -fprofile-arcs -ftest-coverage -O0 -g -Wall -Wno-pointer-sign
|
||||
CFLAGS=-O2 -g -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result
|
||||
ifndef CONFIG_WIN32
|
||||
BCHECK_O=bcheck.o
|
||||
endif
|
||||
CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC
|
||||
LIBS_P=
|
||||
|
||||
CFLAGS+=-mpreferred-stack-boundary=4
|
||||
ifeq ($(GCC_MAJOR),2)
|
||||
CFLAGS+=-m386 -malign-functions=0
|
||||
else
|
||||
CFLAGS+=-falign-functions=0 -fno-strict-aliasing
|
||||
endif
|
||||
|
||||
DISAS=objdump -d
|
||||
INSTALL=install
|
||||
|
||||
ifdef CONFIG_CROSS
|
||||
PROGS+=816-tcc$(EXESUF)
|
||||
endif
|
||||
|
||||
# run local version of tcc with local libraries and includes
|
||||
TCC=./tcc -B. -I.
|
||||
|
||||
all: $(PROGS) \
|
||||
tcc-doc.html tcc.1
|
||||
|
||||
Makefile: config.mak
|
||||
|
||||
# auto test
|
||||
|
||||
test: test.ref test.out
|
||||
@if diff -u test.ref test.out ; then echo "Auto Test OK"; fi
|
||||
|
||||
tcctest.ref: tcctest.c
|
||||
$(CC) $(CFLAGS) -I. -o $@ $<
|
||||
|
||||
test.ref: tcctest.ref
|
||||
./tcctest.ref > $@
|
||||
|
||||
test.out: tcc tcctest.c
|
||||
$(TCC) -run tcctest.c > $@
|
||||
|
||||
run: tcc tcctest.c
|
||||
$(TCC) -run tcctest.c
|
||||
|
||||
# iterated test2 (compile tcc then compile tcctest.c !)
|
||||
test2: tcc tcc.c tcctest.c test.ref
|
||||
$(TCC) -run tcc.c -B. -I. -run tcctest.c > test.out2
|
||||
@if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi
|
||||
|
||||
# iterated test3 (compile tcc then compile tcc then compile tcctest.c !)
|
||||
test3: tcc tcc.c tcctest.c test.ref
|
||||
$(TCC) -run tcc.c -B. -I. -run tcc.c -B. -I. -run tcctest.c > test.out3
|
||||
@if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi
|
||||
|
||||
# binary output test
|
||||
test4: tcc test.ref
|
||||
# dynamic output
|
||||
$(TCC) -o tcctest1 tcctest.c
|
||||
./tcctest1 > test1.out
|
||||
@if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
|
||||
# static output
|
||||
$(TCC) -static -o tcctest2 tcctest.c
|
||||
./tcctest2 > test2.out
|
||||
@if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
|
||||
# object + link output
|
||||
$(TCC) -c -o tcctest3.o tcctest.c
|
||||
$(TCC) -o tcctest3 tcctest3.o
|
||||
./tcctest3 > test3.out
|
||||
@if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
|
||||
# dynamic output + bound check
|
||||
$(TCC) -b -o tcctest4 tcctest.c
|
||||
./tcctest4 > test4.out
|
||||
@if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
|
||||
|
||||
# memory and bound check auto test
|
||||
BOUNDS_OK = 1 4 8 10
|
||||
BOUNDS_FAIL= 2 5 7 9 11 12 13
|
||||
|
||||
btest: boundtest.c tcc
|
||||
@for i in $(BOUNDS_OK); do \
|
||||
if $(TCC) -b -run boundtest.c $$i ; then \
|
||||
/bin/true ; \
|
||||
else\
|
||||
echo Failed positive test $$i ; exit 1 ; \
|
||||
fi ;\
|
||||
done ;\
|
||||
for i in $(BOUNDS_FAIL); do \
|
||||
if $(TCC) -b -run boundtest.c $$i ; then \
|
||||
echo Failed negative test $$i ; exit 1 ;\
|
||||
else\
|
||||
/bin/true ; \
|
||||
fi\
|
||||
done ;\
|
||||
echo Bound test OK
|
||||
|
||||
# speed test
|
||||
speed: tcc ex2 ex3
|
||||
time ./ex2 1238 2 3 4 10 13 4
|
||||
time ./tcc -I. ./ex2.c 1238 2 3 4 10 13 4
|
||||
time ./ex3 35
|
||||
time ./tcc -I. ./ex3.c 35
|
||||
|
||||
ex2: ex2.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
ex3: ex3.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
# Host Tiny C Compiler
|
||||
ifdef CONFIG_WIN32
|
||||
tcc$(EXESUF): tcc.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h tccpe.c
|
||||
$(CC) $(CFLAGS) -DTCC_TARGET_PE -o $@ $< $(LIBS)
|
||||
else
|
||||
ifeq ($(ARCH),i386)
|
||||
tcc$(EXESUF): tcc.c tccelf.c tccasm.c i386-asm.c tcctok.h libtcc.h i386-asm.h
|
||||
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
|
||||
endif
|
||||
ifeq ($(ARCH),arm)
|
||||
tcc$(EXESUF): tcc.c arm-gen.c tccelf.c tccasm.c tcctok.h libtcc.h
|
||||
$(CC) $(CFLAGS) -DTCC_TARGET_ARM -o $@ $< $(LIBS)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Cross Tiny C Compilers
|
||||
816-tcc$(EXESUF): tcc.c 816-gen.c tccelf.c tcctok.h
|
||||
$(CC) $(CFLAGS) -DTCC_TARGET_816 -o $@ $< $(LIBS)
|
||||
|
||||
# windows utilities
|
||||
tiny_impdef$(EXESUF): tiny_impdef.c
|
||||
$(CC) $(CFLAGS) -o $@ $< -lkernel32
|
||||
|
||||
# TinyCC runtime libraries
|
||||
ifdef CONFIG_WIN32
|
||||
# for windows, we must use TCC because we generate ELF objects
|
||||
LIBTCC1_OBJS=$(addprefix win32/lib/, crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o) libtcc1.o
|
||||
LIBTCC1_CC=./tcc.exe -Bwin32
|
||||
else
|
||||
LIBTCC1_OBJS=libtcc1.o
|
||||
LIBTCC1_CC=$(CC)
|
||||
endif
|
||||
|
||||
%.o: %.c
|