Zsolt Branyiczky
527500cedc
instruction table contained wrong parameters at SIR opcode
2020-11-19 22:02:07 +01:00
Zsolt Branyiczky
0e98818db5
assembled SAC and SIR opcodes of 6502DTV cpu were wrong
2020-11-19 22:02:07 +01:00
Zsolt Branyiczky
130d3b52a2
new macros supporting 6502DTV cpu
2020-11-19 22:02:07 +01:00
Zsolt Branyiczky
4205a04a34
6502DTV is not a superset of 6502X more
2020-11-19 22:02:07 +01:00
Polluks
bd6e5927c4
Fixed #1341
2020-11-18 10:28:19 +01:00
Oliver Schmidt
116682c190
Avoid C99 idioms.
2020-11-16 18:08:00 +01:00
Jesse Rosenstock
060417b0dc
Adjust type of int constants that fit in char
...
When there is an integral constant like `3` in an expression, it has
type `int` according to the C spec, even though it can be represented
as an `unsigned char`. Change codegen (`hie_internal` and `typeadjust`)
to treat it as `unsigned char` instead of `int` so that faster,
unsigned operations can be used.
For the test case in #1298 , reduces the cycles per iteration from
4311 to 1884. This is a great improvement, but still much worse than
the 1053 cycles/iter from `c4698df~`, so more work remains to be done.
Further partial fix for #1298 and #1308 .
2020-11-16 00:56:19 +01:00
Greg King
2915464667
Fixed cc65's generation of char-type bit-shift code.
...
Fixed CHAR-to-INT type conversions in the right-shift code generator. Also fixed some printf-style format specifiers.
2020-11-15 15:22:23 -05:00
Zsolt Branyiczky
2d7777b604
Instruction table is synchronized with the c65's one
2020-11-15 16:35:55 +01:00
Zsolt Branyiczky
0f7cf87bfa
Synchronizin InsTab6502DTV instructions table for DTV with the illegal opcodes verified by VICE-emu tests
2020-11-15 16:35:55 +01:00
Zsolt Branyiczky
92c013944e
Mistyped comment, missing comma
2020-11-15 16:35:55 +01:00
Zsolt Branyiczky
b33b053307
add c64dtv support
2020-11-15 16:35:55 +01:00
Jesse Rosenstock
5db74b4b19
Use u16 codegen for u8 x u8 ops
...
In g_typeadjust, before we apply the integral promotions, we check if
both types are unsigned char. If so, we promote to unsigned int, rather
than int, which would be chosen by the standard rules. This is only a
performance optimization and does not affect correctness, as the flags
returned by g_typeadjust are only used for code generation, and not to
determine types of other expressions containing this one. All unsigned
char bit-patterns are valid as both int and unsigned int and represent
the same value, so either signed or unsigned int operations can be used.
This special case part is not duplicated by ArithmeticConvert.
Partial fix for #1308 .
2020-11-09 21:19:22 +01:00
Jesse Rosenstock
b5f0c0468d
Add stdint.h types for C89 compilers
...
Add `intN_t` and `uintN_t` for N = 8, 16, 32.
2020-11-03 21:24:52 +01:00
Jesse Rosenstock
65193c6aaf
Add stdint.h constants INT32_MIN and UINT32_MAX
...
These were missing before
2020-11-03 09:26:26 +01:00
acqn
07cc6a3d20
Made optimization steps aware of long branches better.
2020-10-24 21:25:24 +02:00
acqn
5c43d1e04f
Changed codegen for postfix inc/dec operations by deferring them till sequence points.
...
This usually allows faster & smaller code.
Note that deferred operations must still be called at sequence points even if the whole expressions containing them had constant values.
2020-10-20 22:01:55 +02:00
acqn
bb7b69f513
Added OptShiftBack for shifting the C flag into register A and back.
2020-10-20 21:55:39 +02:00
acqn
0354322413
Added OptSignExtened for testing signness right after sign extention.
2020-10-20 21:55:39 +02:00
acqn
9c776a24e5
Use bcc instead of bne in OptNegAX2 to ease optimizations.
2020-10-20 21:55:39 +02:00
acqn
4f3a96a535
Added new opt OptPushPop2.
...
Also renamed OptPushPop to OptPushPop1.
2020-10-20 21:55:39 +02:00
acqn
262c4235df
Symbols in ZP segments will use '.exportzp' instead of '.export' if exported.
2020-10-11 23:05:20 +02:00
acqn
e58c84acf7
Support for optionally specifying address size for segments with:
...
#pragma ***-name([push,] "name"[, "addrsize"])
where "addrsize" is any addressing size supported in ca65.
2020-10-11 23:05:20 +02:00
acqn
f8c9dde989
The instruction parser can now recognize ZP locations and set the addressing mode for them.
2020-10-11 23:05:20 +02:00
Jesse Rosenstock
81550ca1ee
CS_MergeLabels: Keep labels referenced by data
...
Partial fix for ICE in #1211 . This may fix enough to allow #1049 to be
fixed.
When merging labels, keep the first label with a ref that has no JumpTo;
this is a data segment label, used by computed gotos.
The real fix is to track and rewrite labels in data, but this is more
involved.
2020-10-08 12:11:03 +02:00
acqn
dbba5f3fc9
Fixed handling of %v in inline asm parser.
2020-10-04 12:25:24 +02:00
acqn
a85d5330fa
Fixed StrBuf initialization in PreparseArg().
2020-10-04 12:17:14 +02:00
Jesse Rosenstock
b931e65811
Fix ICE for bit-fields with typedef
...
Fixes #1267
Avoid ICE, but treat plain int bit-fields declared via typedef as
signed rather than unsigned. It is more efficient to treat them
as unsigned, but this requires distinguishing int from signed int,
and this is curently not done.
2020-10-03 15:04:31 +02:00
Greg King
c05a750f47
Fixed some copy-&-paste typo mistakes about HuC6280's TMA mnemonic.
2020-10-01 07:25:08 -04:00
acqn
b525554bfe
Added support for parsing asm byte size expressions with a pair of parentheses.
2020-09-27 12:22:05 +02:00
acqn
688342e194
Now every code entry has its argument parsed to tell some info.
...
It fixes the compiling performance regression as well.
Built-in ZPs are recognized.
2020-09-27 12:22:05 +02:00
acqn
cc0f8422f2
More fixes and new utils to check if opcode arguments can be used elsewhere.
...
Fixed tracking with LI_RELOAD_Y and LI_DIRECT.
Fixed tracking with LI_CHECK_Y and LI_RELOAD_Y.
2020-09-27 12:22:05 +02:00
acqn
f3771a465d
Fixed various issues in the usage-tracking code.
...
Added some utility functions.
2020-09-27 12:22:05 +02:00
acqn
d379affc4b
Moved some reusable code from cc65/coptstop.c into new files.
2020-09-27 12:22:05 +02:00
acqn
28c7aa2bc8
Replaced direct CEF_NUMARG flag checks on code entries with CE_HasNumArg().
2020-09-27 12:22:05 +02:00
acqn
c45a6b3685
Utility function ParseOpcArgStr().
2020-09-27 12:22:05 +02:00
Jesse Rosenstock
d0089aef95
Fix bit-field truncation warning message
...
Fix copy & paste bug with warning message.
struct X {
signed int a : 3;
};
struct X g = { 5 };
Before:
s.c(4): Warning: Implicit truncation from 'int' to 'int : 3' in bit-field
initializer changes value from 5 to 5
After:
s.c(4): Warning: Implicit truncation from 'int' to 'int : 3' in bit-field
initializer changes value from 5 to -3
Fixes #1268
2020-09-26 17:41:45 -04:00
Greg King
81ac28ff71
Used TAY/TYA instead of PHA/PLA when extracting a bit-field.
...
Without optimization, it saves a few CPU cycles. With optimization, it saves more cycles and a few bytes.
2020-09-22 12:47:09 -04:00
Greg King
ea95728330
Avoided an avalanche of messages from bad bit-field declarations.
...
Made cc65 replace a bad bit-field type with a good one, and always parse the field width.
Shortenned a parameter name to a spelling that's consistent with other function headers.
2020-09-22 12:47:09 -04:00
Greg King
07ea5259ac
Changed a cc65 error message to say that the sizes of bit-field types (not bit-fields) are limited.
2020-09-22 12:47:08 -04:00
Greg King
bf4b195016
Added some comments that explain where the g_branch() code generator can and can't be used.
2020-09-18 15:50:26 -04:00
acqn
de630a1245
Fixed quick hack for known registers after calling certain runtime functions,
...
and new quick hack for tosshrax.
2020-09-18 09:04:15 +02:00
acqn
079f4a99dd
Added processor state info to the OPCDesc table. However, since some opcodes are affected by the addressing mode, this info is unused in codegen/optimizer but just as quick in-code documentation/hints.
2020-09-18 09:04:15 +02:00
acqn
a7d6eb9190
Added processor flag usage/change-tracking for non-JSR/RTS code entries.
...
Some existing optimizations are impacted and need fixes in order to work correctly again.
Fixed and improved OptPrecalc. Now it respects the C/V/Z/N flags.
Fixed optimizations impacted by added support of tracking processor flags.
2020-09-18 09:04:15 +02:00
acqn
d02b12fa6c
Made local code/data labels really local to the functions where they live in.
2020-09-18 09:02:16 +02:00
acqn
86ced2bd4c
Avoided unnecessarily boosting the code label numbers with boolean AND.
2020-09-18 08:59:56 +02:00
acqn
b8ae5c28fe
Added debug output support for processor flags.
2020-09-13 13:50:35 +02:00
acqn
810e17edfe
Fixed processor states tracking for the BIT/TRB/TSB opcode.
...
Added new opcode descriptions about whether and how the opcode accesses memory.
2020-09-13 13:50:35 +02:00
acqn
66c5faeb9a
Added processor flags usage tracking.
...
Added ZNRegs for tracking what register(s) Z/N flags currently reflect.
Added utility functions to check if the specified processor state is known to be a certain value.
2020-09-13 13:50:35 +02:00
acqn
fe3f267233
Added new runtime sub bcasta/bcastax/bcasteax opposing to bnega/bnegax/bnegeax.
2020-09-11 13:33:54 +02:00
acqn
142b0bf9b3
Added utility functions to get names of comparison function/transformer subroutines.
2020-09-11 13:33:54 +02:00
acqn
ab7e9f8424
Hotfix for Issue #1250 .
2020-09-08 16:28:21 +02:00
Jesse Rosenstock
4e4e4c2d21
Allow char bit-fields
...
These are not required to be supported (only int, signed int, and
unsigned int are required), but most compilers support it.
https://port70.net/~nsz/c/c89/c89-draft.html#3.5.2.1
https://port70.net/~nsz/c/c89/c89-draft.html#A.6.5.8
For consistency with other integral types, plain `char` bit-fields
are unsigned, regardless of the `--signed-chars` option.
Fixes #1047
2020-09-08 14:24:04 +02:00
acqn
41cee0eb44
Extended support for more addressing modes in tos* optimizations.
2020-09-08 14:19:48 +02:00
acqn
7553b60ef0
Improved OptStackOps for optimizating further when operands have equal hi-bytes.
2020-09-08 14:19:48 +02:00
acqn
57117fa687
Utility functions about compare conditions.
2020-09-08 14:19:48 +02:00
acqn
64ef562fa7
Moved all optimization steps from codeopt.c and some optimization steps from coptind.c into new separate files.
2020-09-08 14:18:22 +02:00
Jesse Rosenstock
9a0e4a35e1
Fix enum bit-field ICE #1244
...
This previously resulted in an ICE:
cc65: Check failed: (Entry->Type->C & T_MASK_SIGN) == T_SIGN_SIGNED,
file 'cc65/symtab.c', line 874
This CHECK is in the code that deals with changing `int` bitfields to
`unsigned int`.
Work around this by treating enum bit-fields as having their signedness
specified, so this type change code does not get called.
Fixes #1244 .
2020-09-07 11:21:23 +02:00
Tevo
1e7a9e44af
Update comment to reflect addition of integer boundary constants
2020-09-06 23:32:00 +02:00
Tevo
23a8b2c303
Define integer size macros for lacking systems
...
Define integer size macros for lacking systems
2020-09-06 23:32:00 +02:00
acqn
6bb2d1d5d1
Fixed a comment on struct/union types in DoCompare().
2020-09-06 22:47:11 +02:00
acqn
1cde952cf5
Fixed comparing an enum type with a non-enum type in DoCompare().
2020-09-06 22:47:11 +02:00
acqn
6e0fb630d7
Fixed check for processor flags usage in case of PHP.
2020-09-06 13:32:38 +02:00
acqn
e2f950b15e
Avoided referencing string literals with sizeof so that they are not output if unused elsewhere.
2020-09-05 13:21:21 +02:00
acqn
903e84c24c
Std-functions are no longer inlined if they are unevaluated.
2020-09-05 13:21:21 +02:00
acqn
df07e23f2c
Fixed bnegeax funcinfo on register usage.
2020-09-05 02:25:56 -04:00
acqn
f849de6769
Object addresses as non-NULL for comparison with NULL.
2020-09-04 19:50:32 +02:00
acqn
8e0b2f0833
Object addresses as non-NULL in boolean context.
2020-09-04 19:50:32 +02:00
acqn
bc5570b708
Fixed logical-NOT in constant context.
2020-09-04 19:50:32 +02:00
acqn
676b14429d
Better opt chance for certain optimization steps e.g. OptPtrStore1 etc.
2020-09-04 12:00:10 +02:00
acqn
29d1999947
Rearranged the OptFunc's in alphabetic order.
2020-09-04 12:00:10 +02:00
acqn
761d00b7dc
Ignore running removed old optimization steps. Neither list them in help info.
2020-09-04 12:00:10 +02:00
acqn
ae340703f2
OptDupLoads shouldn't silently do optimizations.
2020-09-04 11:58:25 +02:00
acqn
f45d2515eb
Fixed OptPush1 in case later code would rely on that pushax zeroes register Y.
2020-09-04 11:58:25 +02:00
acqn
fb6bc275bc
Fixed evaluation flags propagation to subexpressions in assignments and function calls.
2020-09-02 21:36:59 +02:00
acqn
2379504449
Fixed AND/OR in certain cases where the 'E_NEED_TEST' flag set for usage only in subexpressions should be cleared.
2020-09-02 21:36:59 +02:00
acqn
28de3423eb
Merged some switch cases in code generation subroutines.
2020-08-31 09:12:03 +02:00
acqn
6b64b43395
Made local static data use a separated label pool from the code label pool.
2020-08-31 09:12:03 +02:00
acqn
9398e1cd33
Use a dedicated label pool for literals.
2020-08-31 09:12:03 +02:00
Oliver Schmidt
bee559d5f4
Merge pull request #1220 from acqn/StaticConst
...
[cc65] Fixed constant boolean expressions
2020-08-31 08:59:25 +02:00
acqn
74def4608a
The 'E_NEED_TEST' flag shouldn't be overwritten when loading the expression result.
2020-08-31 02:30:12 +08:00
acqn
c0a873e0c8
Reduced exess errors on wrong initializations with curly braces.
2020-08-30 17:35:48 +02:00
acqn
8b580e1191
Disabled struct/union fields of 'void' type.
2020-08-30 17:33:36 +02:00
acqn
f1161daee9
Recursively checking for incomplete/unknown-sized types.
2020-08-30 17:33:36 +02:00
acqn
8541f18340
Improved diagnostic info on assignment to void types.
2020-08-30 17:33:36 +02:00
acqn
abcc2a8f1a
Disallowed void arrays of elements of variant sizes.
2020-08-30 17:33:36 +02:00
acqn
d87846e1e1
Improved comments according to PR reviews.
2020-08-30 22:12:30 +08:00
acqn
60c59f59a3
Renamed StaticConstExpr() and StaticConstAbsIntExpr() with clearer comments.
2020-08-30 00:26:52 +08:00
acqn
df755df44d
Warning about ESU types declared inside parameter list as they are invisble outside.
2020-08-29 16:37:16 +02:00
acqn
33a75e0a73
Optimized parameter list checking.
...
Fixed function type comparison between ANSI and K&R styles.
2020-08-29 16:37:16 +02:00
acqn
0a96ffc878
Fixed function parameter checking.
...
Fixed function return type checking.
2020-08-29 16:37:16 +02:00
acqn
4e61ae5b36
Fixed function parameter type conversion.
2020-08-29 16:37:16 +02:00
acqn
632da3f4ee
Fixed tracking and checking flexible array members.
2020-08-29 16:35:42 +02:00
acqn
504aee3835
Merge branch 'master' into StaticConst
2020-08-27 06:27:23 +08:00
acqn
bb9c203222
Fixed integer promotion of unary operations.
2020-08-26 22:17:16 +02:00
acqn
8d225c32b1
Fixed checks on assignment to incomplete types.
2020-08-26 22:14:51 +02:00
acqn
43cb092a68
Fixed CHECK failures on certain usage of incomplete enums.
2020-08-26 22:14:51 +02:00
acqn
1957dc7a5c
Disallowed arrays of incomplete types.
...
Fixed diagnostics on incomplete local arrays.
2020-08-26 22:14:51 +02:00
acqn
f5b1b69376
Forbid struct/union fields of incomplete types.
2020-08-26 22:14:51 +02:00
Jesse Rosenstock
d38e5858f0
Add tests for #1211
...
CL_MoveRefs: Add CHECK (E->JumpTo != NULL) to make failure clearer.
2020-08-24 18:10:22 +02:00