@@ -90,6 +90,12 @@ To build the plugin, you need GCC with plugin support enabled.
9090make
9191```
9292
93+ On macOS, prefer Homebrew GCC and set the toolchain explicitly:
94+
95+ ``` bash
96+ make CXX=g++-15 CC=gcc-15
97+ ```
98+
9399Alternatively, with CMake (requires GMP and other deps):
94100
95101``` bash
@@ -110,6 +116,10 @@ Optional arguments:
110116
111117- ` -fplugin-arg-ternary_plugin-warn ` emits a warning for each ternary operator.
112118- ` -fplugin-arg-ternary_plugin-stats ` prints a summary at the end of compilation.
119+ - ` -fplugin-arg-ternary_plugin-version ` prints the plugin version and GCC version.
120+ - ` -fplugin-arg-ternary_plugin-selftest ` prints a brief self-test summary of enabled features.
121+ - ` -fplugin-arg-ternary_plugin-trace ` logs lowering decisions for matching statements.
122+ - ` -fplugin-arg-ternary_plugin-dump-gimple ` dumps matching GIMPLE statements before rewriting.
113123- ` -fplugin-arg-ternary_plugin-lower ` replaces ternary operators with calls to
114124 ` __ternary_select_[i|u]<bits> ` for integral result types (e.g., ` __ternary_select_i32 ` )
115125 and ` __ternary_select_f32 ` or ` __ternary_select_f64 ` for floating-point types.
@@ -128,6 +138,14 @@ Optional arguments:
128138- ` -fplugin-arg-ternary_plugin-prefix=<name> ` sets the function name prefix used by ` -lower `
129139 (default: ` __ternary_select ` ).
130140
141+ Example with trace/dumps enabled:
142+
143+ ``` bash
144+ gcc -fplugin=./ternary_plugin.so -fplugin-arg-ternary_plugin-lower \
145+ -fplugin-arg-ternary_plugin-trace -fplugin-arg-ternary_plugin-dump-gimple \
146+ -Iinclude -c source.c
147+ ```
148+
131149## Implementing the Helpers
132150
133151When using ` -lower ` , the plugin emits calls to external functions like ` __ternary_select_i32 ` .
@@ -136,12 +154,15 @@ You need to provide implementations for these functions, tailored to your ternar
136154Include ` include/ternary_helpers.h ` in your code, which provides example implementations using
137155placeholder ternary ISA instructions (for example, ` tsel ` , ` tadd ` , ` tmul ` , ` tnot ` ). Adjust the
138156assembly to match your ISA. ` TERNARY_COND_T ` defines the condition type used by select helpers
139- and must match the source condition type (defaults to ` bool ` ).
157+ and is fixed to ` ternary_cond_t ` (default: ` int64_t ` ). The plugin lowers conditions to
158+ ` ternary_cond_t ` before helper calls.
140159
141160For testing without the plugin, the header provides C implementations of all ternary operations.
142161Packed ternary types use a 2-bit encoding per trit (00 = -1, 01 = 0, 10 = +1).
143162Define ` TERNARY_USE_BUILTIN_TYPES ` before including the header when compiling with
144163` -fplugin-arg-ternary_plugin-types ` to avoid typedef conflicts.
164+ Helper/runtime support is currently provided for t6/t12/t24 only; t48/t96/t192 require
165+ custom runtime implementations.
145166
146167For example:
147168
@@ -165,7 +186,7 @@ gcc -fplugin=./ternary_plugin.so -fplugin-arg-ternary_plugin-lower -Iinclude -c
165186For a minimal out-of-line runtime, use the reference implementation in ` runtime/ternary_runtime.c `
166187with the public header ` include/ternary_runtime.h ` . It implements the same packed 2-bit-trit
167188semantics as the helpers (t6/t12/t24) and is intended as a starting point for a real ISA-backed
168- library.
189+ library. Packed helpers for t48/t96/t192 are not provided in this reference runtime.
169190
170191Example build:
171192
@@ -184,6 +205,12 @@ gcc -fplugin=./ternary_plugin.so -fplugin-arg-ternary_plugin-lower \
184205 -fplugin-arg-ternary_plugin-conv -Iinclude -c test_ternary.c
185206```
186207
208+ On macOS, run:
209+
210+ ``` bash
211+ make test CXX=g++-15 CC=gcc-15
212+ ```
213+
187214## Description
188215
189216This plugin analyzes ternary conditional expressions in the code and can optionally
0 commit comments