Remove the deprecated -H/-h/-L/-l options

This commit is contained in:
Rangi42
2024-03-22 15:14:11 -04:00
committed by Sylvie
parent 106e516962
commit 14b72222b1
12 changed files with 11 additions and 248 deletions

View File

@@ -26,10 +26,6 @@ _rgbasm_completions() {
declare -A opts=( declare -A opts=(
[V]="version:normal" [V]="version:normal"
[E]="export-all:normal" [E]="export-all:normal"
[H]="nop-after-halt:normal"
[h]="halt-without-nop:normal"
[L]="preserve-ld:normal"
[l]="auto-ldh:normal"
[v]="verbose:normal" [v]="verbose:normal"
[w]=":normal" [w]=":normal"
[b]="binary-digits:unk" [b]="binary-digits:unk"

View File

@@ -37,10 +37,6 @@ local args=(
'(- : * options)'{-V,--version}'[Print version number]' '(- : * options)'{-V,--version}'[Print version number]'
'(-E --export-all)'{-E,--export-all}'[Export all symbols]' '(-E --export-all)'{-E,--export-all}'[Export all symbols]'
'(-H --nop-after-halt)'{-H,--nop-after-halt}'[Output a `nop` after `halt`]'
'(-h --halt-without-nop)'{-h,--halt-without-nop}'[Prevent outputting a `nop` after `halt`]'
'(-L --preserve-ld)'{-L,--preserve-ld}'[Prevent optimizing `ld` into `ldh`]'
'(-l --auto-ldh)'{-l,--auto-ldh}'[Optimize `ld` into `ldh`]'
'(-v --verbose)'{-v,--verbose}'[Print additional messages regarding progression]' '(-v --verbose)'{-v,--verbose}'[Print additional messages regarding progression]'
-w'[Disable all warnings]' -w'[Disable all warnings]'

View File

@@ -6,10 +6,6 @@
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
extern bool haltNop;
extern bool warnOnHaltNop;
extern bool optimizeLoads;
extern bool warnOnLdOpt;
extern bool verbose; extern bool verbose;
extern bool warnings; // True to enable warnings, false to disable them. extern bool warnings; // True to enable warnings, false to disable them.

View File

@@ -9,7 +9,6 @@ void opt_B(char const chars[2]);
void opt_G(char const chars[4]); void opt_G(char const chars[4]);
void opt_P(uint8_t padByte); void opt_P(uint8_t padByte);
void opt_Q(uint8_t precision); void opt_Q(uint8_t precision);
void opt_L(bool optimize);
void opt_W(char const *flag); void opt_W(char const *flag);
void opt_Parse(char const *option); void opt_Parse(char const *option);

View File

@@ -66,15 +66,6 @@ Export all labels, including unreferenced and local labels.
.It Fl g Ar chars , Fl \-gfx-chars Ar chars .It Fl g Ar chars , Fl \-gfx-chars Ar chars
Change the four characters used for gfx constants. Change the four characters used for gfx constants.
The defaults are 0123. The defaults are 0123.
.It Fl H , Fl \-nop-after-halt
Inserts a
.Ic nop
instruction immediately after any
.Ic halt
instruction.
This option is deprecated and will be removed in the next version.
.It Fl h , Fl \-halt-without-nop
This option is redundant and will be removed in the next version.
.It Fl I Ar path , Fl \-include Ar path .It Fl I Ar path , Fl \-include Ar path
Add a new Add a new
.Dq include path ; .Dq include path ;
@@ -90,14 +81,6 @@ is attempted,
first looks up the provided path from its working directory; if this fails, it tries again from each of the first looks up the provided path from its working directory; if this fails, it tries again from each of the
.Dq include path .Dq include path
directories, in the order they were provided. directories, in the order they were provided.
.It Fl L , Fl \-preserve-ld
This option is redundant and will be removed in the next version.
.It Fl l , Fl \-auto-ldh
Optimize loads of the form
.Ic LD [$FF00+n8],A
into the opcode
.Ic LDH [$FF00+n8],A .
This option is deprecated and will be removed in the next version.
.It Fl M Ar depend_file , Fl \-dependfile Ar depend_file .It Fl M Ar depend_file , Fl \-dependfile Ar depend_file
Print Print
.Xr make 1 .Xr make 1

View File

@@ -641,23 +641,6 @@ can range from
.Ad $FF80 .Ad $FF80
to to
.Ad $FFFE . .Ad $FFFE .
.Pp
.Sy Note :
While
.Nm
will automatically optimize
.Ic ld
instructions to the smaller and faster
.Ic ldh
(see
.Xr gbz80 7 )
whenever possible, it is generally unable to do so when a label is involved.
Using the
.Ic ldh
instruction directly is recommended.
This forces the assembler to emit a
.Ic ldh
instruction and the linker to check if the value is in the correct range.
.El .El
.Pp .Pp
Since RGBDS produces ROMs, code and data can only be placed in Since RGBDS produces ROMs, code and data can only be placed in
@@ -2105,29 +2088,20 @@ can be used to change some of the options during assembling from within the sour
takes a comma-separated list of options as its argument: takes a comma-separated list of options as its argument:
.Bd -literal -offset indent .Bd -literal -offset indent
PUSHO PUSHO
OPT g.oOX, Wdiv, L ; acts like command-line -g.oOX -Wdiv -L OPT g.oOX, Wdiv ; acts like command-line -g.oOX -Wdiv
DW `..ooOOXX ; uses the graphics constant characters from OPT g DW `..ooOOXX ; uses the graphics constant characters from OPT g
PRINTLN $80000000/-1 ; prints a warning about division PRINTLN $80000000/-1 ; prints a warning about division
LD [$FF88], A ; encoded as LD, not LDH
POPO POPO
DW `00112233 ; uses the default graphics constant characters DW `00112233 ; uses the default graphics constant characters
PRINTLN $80000000/-1 ; no warning by default PRINTLN $80000000/-1 ; no warning by default
LD [$FF88], A ; optimized to use LDH by default
.Ed .Ed
.Pp .Pp
The options that The options that
.Ic OPT .Ic OPT
can modify are currently: can modify are currently:
.Cm b , g , p , Q , r , h , L , .Cm b , g , p , Q ,
and and
.Cm W . .Cm r .
The Boolean flag options
.Cm H , h , L ,
and
.Cm l
can be negated like
.Ql OPT !H
to act like omitting them from the command-line.
.Pp .Pp
.Ic POPO .Ic POPO
and and

View File

@@ -27,10 +27,6 @@ bool failedOnMissingInclude = false;
bool generatePhonyDeps = false; bool generatePhonyDeps = false;
std::string targetFileName; std::string targetFileName;
bool haltNop;
bool warnOnHaltNop;
bool optimizeLoads;
bool warnOnLdOpt;
bool verbose; bool verbose;
bool warnings; // True to enable warnings, false to disable them. bool warnings; // True to enable warnings, false to disable them.
@@ -52,7 +48,7 @@ static std::string make_escape(std::string &str) {
} }
// Short options // Short options
static char const *optstring = "b:D:Eg:Hhi:I:LlM:o:P:p:Q:r:VvW:wX:"; static char const *optstring = "b:D:Eg:i:I:M:o:P:p:Q:r:VvW:wX:";
// Variables for the long-only options // Variables for the long-only options
static int depType; // Variants of `-M` static int depType; // Variants of `-M`
@@ -70,11 +66,7 @@ static option const longopts[] = {
{"define", required_argument, nullptr, 'D'}, {"define", required_argument, nullptr, 'D'},
{"export-all", no_argument, nullptr, 'E'}, {"export-all", no_argument, nullptr, 'E'},
{"gfx-chars", required_argument, nullptr, 'g'}, {"gfx-chars", required_argument, nullptr, 'g'},
{"nop-after-halt", no_argument, nullptr, 'H'},
{"halt-without-nop", no_argument, nullptr, 'h'},
{"include", required_argument, nullptr, 'I'}, {"include", required_argument, nullptr, 'I'},
{"preserve-ld", no_argument, nullptr, 'L'},
{"auto-ldh", no_argument, nullptr, 'l'},
{"dependfile", required_argument, nullptr, 'M'}, {"dependfile", required_argument, nullptr, 'M'},
{"MG", no_argument, &depType, 'G'}, {"MG", no_argument, &depType, 'G'},
{"MP", no_argument, &depType, 'P'}, {"MP", no_argument, &depType, 'P'},
@@ -95,7 +87,7 @@ static option const longopts[] = {
static void printUsage() { static void printUsage() {
fputs( fputs(
"Usage: rgbasm [-EHhLlVvw] [-b chars] [-D name[=value]] [-g chars] [-I path]\n" "Usage: rgbasm [-EVvw] [-b chars] [-D name[=value]] [-g chars] [-I path]\n"
" [-M depend_file] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n" " [-M depend_file] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n"
" [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\n" " [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\n"
" [-r depth] [-W warning] [-X max_errors] <file>\n" " [-r depth] [-W warning] [-X max_errors] <file>\n"
@@ -132,10 +124,6 @@ int main(int argc, char *argv[]) {
opt_G("0123"); opt_G("0123");
opt_P(0); opt_P(0);
opt_Q(16); opt_Q(16);
haltNop = false;
warnOnHaltNop = true;
optimizeLoads = false;
warnOnLdOpt = true;
verbose = false; verbose = false;
warnings = true; warnings = true;
sym_SetExportAll(false); sym_SetExportAll(false);
@@ -179,21 +167,6 @@ int main(int argc, char *argv[]) {
errx("Must specify exactly 4 characters for option 'g'"); errx("Must specify exactly 4 characters for option 'g'");
break; break;
case 'H':
if (warnOnHaltNop)
warning(
WARNING_OBSOLETE, "Automatic `nop` after `halt` (the `-H` flag) is deprecated\n"
);
else
errx("`-H` and `-h` don't make sense together");
haltNop = true;
warnOnHaltNop = false;
break;
case 'h':
if (haltNop)
errx("`-H` and `-h` don't make sense together");
break;
// `-i` was the only short option for `--include` until `-I` was // `-i` was the only short option for `--include` until `-I` was
// introduced to better match the `-I dir` option of gcc and clang. // introduced to better match the `-I dir` option of gcc and clang.
case 'i': case 'i':
@@ -203,22 +176,6 @@ int main(int argc, char *argv[]) {
fstk_AddIncludePath(musl_optarg); fstk_AddIncludePath(musl_optarg);
break; break;
case 'L':
if (optimizeLoads)
errx("`-L` and `-l` don't make sense together");
break;
case 'l':
if (warnOnLdOpt)
warning(
WARNING_OBSOLETE,
"Automatic `ld` to `ldh` optimization (the `-l` flag) is deprecated\n"
);
else
errx("`-L` and `-l` don't make sense together");
optimizeLoads = true;
warnOnLdOpt = false;
break;
case 'M': case 'M':
if (dependFile) if (dependFile)
warnx("Overriding dependfile %s", dependFileName); warnx("Overriding dependfile %s", dependFileName);

View File

@@ -21,10 +21,6 @@ struct OptStackEntry {
char gbgfx[4]; char gbgfx[4];
uint8_t fixPrecision; uint8_t fixPrecision;
uint8_t fillByte; uint8_t fillByte;
bool haltNop;
bool warnOnHaltNop;
bool optimizeLoads;
bool warnOnLdOpt;
bool warningsAreErrors; bool warningsAreErrors;
size_t maxRecursionDepth; size_t maxRecursionDepth;
WarningState warningStates[numWarningStates]; WarningState warningStates[numWarningStates];
@@ -53,22 +49,6 @@ void opt_R(size_t newDepth) {
lexer_CheckRecursionDepth(); lexer_CheckRecursionDepth();
} }
void opt_H(bool warn) {
warnOnHaltNop = warn;
}
void opt_h(bool halt) {
haltNop = halt;
}
void opt_L(bool optimize) {
optimizeLoads = optimize;
}
void opt_l(bool warn) {
warnOnLdOpt = warn;
}
void opt_W(char const *flag) { void opt_W(char const *flag) {
processWarningFlag(flag); processWarningFlag(flag);
} }
@@ -150,34 +130,6 @@ void opt_Parse(char const *s) {
break; break;
} }
case 'H':
if (s[1] == '\0')
opt_H(false);
else
error("Option 'H' does not take an argument\n");
break;
case 'h':
if (s[1] == '\0')
opt_h(false);
else
error("Option 'h' does not take an argument\n");
break;
case 'L':
if (s[1] == '\0')
opt_L(false);
else
error("Option 'L' does not take an argument\n");
break;
case 'l':
if (s[1] == '\0')
opt_l(false);
else
error("Option 'l' does not take an argument\n");
break;
case 'W': case 'W':
if (strlen(&s[1]) > 0) if (strlen(&s[1]) > 0)
opt_W(&s[1]); opt_W(&s[1]);
@@ -185,42 +137,6 @@ void opt_Parse(char const *s) {
error("Must specify an argument for option 'W'\n"); error("Must specify an argument for option 'W'\n");
break; break;
case '!': // negates flag options that do not take an argument
switch (s[1]) {
case 'H':
if (s[2] == '\0')
opt_H(true);
else
error("Option '!H' does not take an argument\n");
break;
case 'h':
if (s[2] == '\0')
opt_h(true);
else
error("Option '!h' does not take an argument\n");
break;
case 'L':
if (s[2] == '\0')
opt_L(true);
else
error("Option '!L' does not take an argument\n");
break;
case 'l':
if (s[2] == '\0')
opt_l(true);
else
error("Option '!l' does not take an argument\n");
break;
default:
error("Unknown option '!%c'\n", s[1]);
break;
}
break;
default: default:
error("Unknown option '%c'\n", s[0]); error("Unknown option '%c'\n", s[0]);
break; break;
@@ -243,14 +159,6 @@ void opt_Push() {
entry.fillByte = fillByte; // Pulled from section.hpp entry.fillByte = fillByte; // Pulled from section.hpp
// Both of these are pulled from main.hpp
entry.haltNop = haltNop;
entry.warnOnHaltNop = warnOnHaltNop;
// Both of these are pulled from main.hpp
entry.optimizeLoads = optimizeLoads;
entry.warnOnLdOpt = warnOnLdOpt;
// Both of these pulled from warning.hpp // Both of these pulled from warning.hpp
entry.warningsAreErrors = warningsAreErrors; entry.warningsAreErrors = warningsAreErrors;
memcpy(entry.warningStates, warningStates, numWarningStates); memcpy(entry.warningStates, warningStates, numWarningStates);
@@ -273,10 +181,6 @@ void opt_Pop() {
opt_G(entry.gbgfx); opt_G(entry.gbgfx);
opt_P(entry.fillByte); opt_P(entry.fillByte);
opt_Q(entry.fixPrecision); opt_Q(entry.fixPrecision);
opt_H(entry.warnOnHaltNop);
opt_h(entry.haltNop);
opt_L(entry.optimizeLoads);
opt_l(entry.warnOnLdOpt);
opt_R(entry.maxRecursionDepth); opt_R(entry.maxRecursionDepth);
// opt_W does not apply a whole warning state; it processes one flag string // opt_W does not apply a whole warning state; it processes one flag string

View File

@@ -1870,16 +1870,6 @@ z80_ei:
z80_halt: z80_halt:
Z80_HALT { Z80_HALT {
sect_AbsByte(0x76); sect_AbsByte(0x76);
if (haltNop) {
if (warnOnHaltNop) {
warnOnHaltNop = false;
warning(
WARNING_OBSOLETE,
"Automatic `nop` after `halt` (option 'H') is deprecated\n"
);
}
sect_AbsByte(0x00);
}
} }
; ;
@@ -2002,20 +1992,8 @@ z80_ld_mem:
sect_RelWord($2, 1); sect_RelWord($2, 1);
} }
| Z80_LD op_mem_ind COMMA MODE_A { | Z80_LD op_mem_ind COMMA MODE_A {
if (optimizeLoads && $2.isKnown && $2.val >= 0xFF00) { sect_AbsByte(0xEA);
if (warnOnLdOpt) { sect_RelWord($2, 1);
warnOnLdOpt = false;
warning(
WARNING_OBSOLETE,
"Automatic `ld` to `ldh` optimization (option 'l') is deprecated\n"
);
}
sect_AbsByte(0xE0);
sect_AbsByte($2.val & 0xFF);
} else {
sect_AbsByte(0xEA);
sect_RelWord($2, 1);
}
} }
; ;
@@ -2059,20 +2037,8 @@ z80_ld_a:
} }
| Z80_LD reg_r COMMA op_mem_ind { | Z80_LD reg_r COMMA op_mem_ind {
if ($2 == REG_A) { if ($2 == REG_A) {
if (optimizeLoads && $4.isKnown && $4.val >= 0xFF00) { sect_AbsByte(0xFA);
if (warnOnLdOpt) { sect_RelWord($4, 1);
warnOnLdOpt = false;
warning(
WARNING_OBSOLETE,
"Automatic `ld` to `ldh` optimization (option 'l') is deprecated\n"
);
}
sect_AbsByte(0xF0);
sect_AbsByte($4.val & 0xFF);
} else {
sect_AbsByte(0xFA);
sect_RelWord($4, 1);
}
} else { } else {
::error("Destination operand must be A\n"); ::error("Destination operand must be A\n");
} }

View File

@@ -1,22 +1,14 @@
SECTION "test", ROM0 SECTION "test", ROM0
opt !h, !L ; already the default, but tests parsing "!"
pusho pusho
opt p42, Q.4, h, L, Wno-div opt p42, Q.4, Wno-div
ds 1 ds 1
ld [$ff88], a
halt
println $8000_0000 / -1 println $8000_0000 / -1
def n = 3.14 def n = 3.14
println "{x:n} = {f:n}" println "{x:n} = {f:n}"
popo popo
opt H, l
ds 1 ds 1
ld [$ff88], a
halt
println $8000_0000 / -1 println $8000_0000 / -1
def n = 3.14 def n = 3.14
println "{x:n} = {f:n}" println "{x:n} = {f:n}"

View File

@@ -1,2 +1,2 @@
warning: opt.asm(20): [-Wdiv] warning: opt.asm(12): [-Wdiv]
Division of -2147483648 by -1 yields -2147483648 Division of -2147483648 by -1 yields -2147483648

Binary file not shown.