Releases: llvm-mos/llvm-mos-sdk
SDK v0.11.1
New targets
- The NES MMC3 target is now complete and tested.
Bug fixes
-
#89 - Check for the batch file version for mos-clang platforms
- This fixed an issue that prevented successful builds using the CMake toolchain config on Windows. Thanks @jroweboy !
-
llvm-mos/llvm-mos#243 - Inline asm branch to wrong location
- This fixed an issue where the assembler would fail to emit a relocation for unknown branch targets, which could cause invalid code generation. Only affects assembler and inline assembly.
Optimizations
- Small functions in the NES neslib and nesdoug libraries were rewritten in C. Combined with LTO, this allows them to be inlined. Given that a number of functions are essentially accessors and mutators for global state, this can dramatically improve the code sequences that involve them.
Misc
-
Integrated changes from upstream LLVM.
-
llvm-objdump now prints instruction arguments in hexadecimal by default.
SDK v0.11.0
Breaking changes
-
.init priorities have been rescaled from 10, 20 to 100, 200, to give more room between init events.
-
Famitone2 no longer automatically initializes sounds using sounds_data and music using music_data. Users should expcility call initialization functions before using the library. This allows banked use cases to work, since they depend on initializing the library more than once.
Bug fixes
-
Fixed a pair of issues (llvm-mos/llvm-mos#236, llvm-mos/llvm-mos#237) which caused codegen to hang on 128-bit operations. This affected the rust-mos standard library.
-
Fixed llvm-mos/llvm-mos#131, which caused Mac builds to fail when using
-DBUILD_SHARED_LIBS=ON
. Thanks, @pfusik ! -
Fixed an issue, also found by @pfusik , where a comparison with zero would be incorrectly elided with a preceding inline assembly fragment, which may not have set N and Z to the expected values.
Optimizations
- The neslib library has been broken up somewhat so that NMI and init functionality for unused portions can be better GCed away.
Library features
-
Famitone2 now includes a library that provides fixed-bank wrappers, for when the library is in a bank. It also now supports setting the banks for music and data, for when these are in a different bank from the library.
-
NES libraries now dynamically build a NMI routine based on what's actually linked into the program. The user can override this default NMI routine and provide their own. To facilitate this, all NMI routines provided by libraries are accessible via a simple JSR.
-
NES targets now have a generic
.chr_rom
section that allows completely controlling the layout of CHR-ROM banks. This is useful if you want to use a single binary file to set all banks. -
The
cbm_k
functions have been added tocbm.h
for all Commodore targets. #87. Thanks, @cnelson20 ! -
getchar()
has now been implemented for Atari8. #88. Thanks, @pfusik ! -
There are now
BRK()
,CLI()
, andSEI()
macros that generate the respective instructions, available in6502.h
.
SDK v0.10.1
Bug Fixes
- Fixed llvm-mos/llvm-mos#238 - Linkage to non-existent libzstd.1.dylib on MacOS: Breakage in MacOS binaries due to unintentional dependency on Homebrew ZSTD library present on Github Actions builders, but not in stock MacOS image.
- Fixed llvm-mos/llvm-mos#235 - @llvm.smul.with.overflow.i64 hangs compiler
- Fixed llvm-mos/llvm-mos#234 - @llvm.fshl hangs compiler: This fixes an issue where detecting an integer rotation pattern produced an infinite loop in the backend.
SDK v0.10.0
Breaking changes
- Removed stub PPU functions from NES target.
New targets
- Added NES-CNROM target.
New functionality
- Added padlib and zaplib functions to nesdoug library.
- Added banking library to MMC1's libc.
- The third byte of PRG VMAs is now the bank number.
- Neslib's NMI handler and famitone2 now support PRG and CHR banking.
Bug fixes
- Unhandled addresses are now reported to Mesen as "register labels".
- Various bug-fixes to neslib, nesdoug, and famitone2 libraries.
Optimizations
- The legalizer now uses known bits information to select 8-bit addressing whenever it can prove that the high 8 bits of a pointer offset are all zero.
- Callee-saved registers are no longer saved or restored for functions that can be proven never to return. (Thanks Anshil!)
SDK v0.9.2
Bug fixes
- The linker will now emit errors for relative branches that are out of range. Previously, this would result in a miscompile. Note that the compiler should never generate these; they should only be possible via hand-written assembly.
New features
- The compiler now supports the
.hword
,.word
,.dword
, and.xword
directives, for 1, 2, 4, and 8 byte values, respectively. - The NES target now includes a port of the Famitone2 library. The SDK also includes a llvm-mos port of the included assembly generation utilities. The library has been modified to be placeable anywhere in memory by the linker, and no hand-edits are required to use it.
- The NES target has a new
.dpcm
section, which places DPCM data with the alignment (64 bytes) and address (>=$c000) necessary for the APU. It also generates a__dpcm_offset
symbol to the start of the section in the format the APU expects (addr >> 6). The famitone2 port picks up samples from this section using usual linker relocation mechanisms; no hand edits are necessary.
SDK v0.9.1
New libraries
- The nesdoug library has been added to the NES target and is accessible via
-lnesdoug
. It is likely buggy and should be considered alpha quality.
Bug fixes
- Added C++
extern C
declarations to the neslib library. - The
neslib
crt0 additions now clear memory before copying.data
, not after. This had the effect of zeroing all data segments. - Misc small cleanups and bug fixes to the neslib port.
- BSS and Data section zero and copy routines no longer run if a section coincidentally begins with the prefix. Instead, the prefix must end with a dot, followed by another name. For example, a
.data_ptr
section will no longer trigger data copying, while.data.ptr
and.data
both still would.
Optimizations
- The register allocator will no longer place a value into a register such that the only uses of that register are copies out of it to physical registers. It will instead prefer to split the live range into something that can be assigned to the destination physical register. This has the particular effect of rematerializing constant loads used as function arguments to right before the call, rather than stashing them in the zero page.
- Multi-byte comparisons against zero no longer consider bytes that are statically known to be zero.
- Sums where one addend is either -1 or 1, depending on control flow, are split into separate increment and decrement operations.
- An expensive copy optimization pass was added right before copy elimination. This helps to remove some of the worse excesses of the register allocator, and this brings our CoreMark score up to 0.089 from 0.088. (A rare occurrence!)
SDK v0.9.0
New Features
- Added nesdoug's port of Shiru's neslib to the SDK. This isn't included by default, but can be used with
-lneslib
. The library needed to be ported by hand, and it isn't very well tested, so it should be considered alpha quality at best, and wholly broken at worst. As work continues porting the nesdoug tutorial series to llvm-mos, the library will get more reliable, and this will be reported in future release notes. - Zero page allocation now takes into account symbols given explicit sections in the zero page. The sizes of those symbols are deducted from the amount given to the compiler for zero page use. This allows assembly libraries to ship their zero page symbols as bitcode, which allows users to safely use the library without needing to manually specify
-mreserve-zp
. - Added
llvm-mlb
utility to generate Mesen label files (.mlb
) from ELF binaries. The Clang driver now automatically runs this after the link step for NES targets in the SDK. - Added the
-fpost-link-tool=
compiler option used to implement the above. - The compiler now correctly sets the
SHT_NOBITS
section type for symbols placed in zero-page BSS, zero-page noinit, and generalized noinit sections (i.e., any section ending in.noinit
or containing.noinit.
).
SDK v0.8
Breaking Changes
- The compiler driver now only provides the default linker script (
-Tlink.ld
) if no-T
flag is explicitly given on the command line. This allows completely overriding the default linker script. - The NES targets have been completely reworked. They now support a fairly broad subset of their respective mappers (NROM and MMC1). As far as possible, the linker scripts are configured by defining symbol values. Some configuration requires forming a custom linker script by INCLUDE-ing snippets to form the configuration. The linker scripts support PRG-ROM/(NV)RAM and CHR-ROM/(NV)RAM banking of various sizes, with the option to place the C sections into either NES RAM or PRG-RAM.
New Features
- The linker now supports an
OVERLAY
output section flag to cause the VMAs of that section not to be checked for overlap, just like with the OVERLAY syntax. The OVERLAY syntax is unfortunately too restrictive for typical 6502 targets with banked ROMs, as it requires that the LMAs of banks with the same VMA be contiguous.
Misc
- The
_exit
function defined in theexit-loop
library is now a weak symbol. Exiting by infinite loop is a fallback used when there's no better option. Accordingly, it should be left open for users to supply a better one. - The SDK now runs NES tests in continuous integration using the Mesen emulator's test-runner mode. As a result, the NES linker scripts are fairly well tested now, better even than most of the rest of the SDK, which relies only on manual testing and the simulator target.
SDK v0.7.1
New Targets
- #51
cx16
— Commander X16. Partial support was previously available through the c64 target, but this target adds native support.
Bug Fixes
-
llvm-mos/llvm-mos#213 —
-mcpu=
now produces an error when an incorrect CPU type is given. -
The NES status registers are now unsigned. The cc65 definitions were signed due to an obscure cc65-specific codegen issue.
-
#69 — The
PEEK
andPOKE
macros imported from cc65 now usevolatile
. Previously, the compiler may have optimized them away. -
#73 — The MEGA65 target now uses the
mos65ce02
CPU type. Previously, this was the defaultmos6502
, which restricted functionality to that avaiable on a vanilla NMOS 6502.
Miscellaneous
-
The SDK was relicensed to use the Apache License v2.0 with LLVM Exceptions. Previously, it did not include the LLVM exceptions, which technically required that distributions of binaries compiled against the SDK include a copy of the Apache License.
-
Upstream LLVM was merged at 65923012b3.
SDK v0.7.0
Breaking Changes
- llvm-mos/llvm-mos#209: LLVM-MOS specific optimization passes are now generally disabled at -O0, just like regular optimization passes. These passes ignored optimization level for simplicity sake, but now they don't. This means that functions compiled at -O0 will use soft stacks and won't allocate zero page (other than the regular use of imaginary registers).
- The hardware register definitions from cc65 were ported for all supported platforms. Conflicting functionality in the SDK was replaced with its cc65 equivalent.
New Features
- cc65's
peekpoke.h
was ported to the SDK.
Bug fixes
- llvm-mos/llvm-mos#208: The CLD instruction at the beginning of a C interrupt handler was placed after the stack was adjusted. Since adjusting the stack requires an addition, the result of the addition may have been incorrect.
- llvm-mos/llvm-mos#206: There were two cases where the compiler would produce incorrect assembly. This only affected assembly output, since clang goes directly from C to machine code. If assembled later, the first case would fail, and the second would assemble to a different opcode than was emitted.
- DODO API functions no longer prevent the allocation of ZP. Linker script support was also fixed.
Optimizations
- llvm-mos/llvm-mos#210: Zero page locations can now be allocated to functions that appear to recurse in the call graph, but are known for other reasons not to ever recurse. For example, for main in C++ to recurse is undefined behavior, so it can now always allocate ZP.