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

@@ -27,10 +27,6 @@ bool failedOnMissingInclude = false;
bool generatePhonyDeps = false;
std::string targetFileName;
bool haltNop;
bool warnOnHaltNop;
bool optimizeLoads;
bool warnOnLdOpt;
bool verbose;
bool warnings; // True to enable warnings, false to disable them.
@@ -52,7 +48,7 @@ static std::string make_escape(std::string &str) {
}
// 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
static int depType; // Variants of `-M`
@@ -70,11 +66,7 @@ static option const longopts[] = {
{"define", required_argument, nullptr, 'D'},
{"export-all", no_argument, nullptr, 'E'},
{"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'},
{"preserve-ld", no_argument, nullptr, 'L'},
{"auto-ldh", no_argument, nullptr, 'l'},
{"dependfile", required_argument, nullptr, 'M'},
{"MG", no_argument, &depType, 'G'},
{"MP", no_argument, &depType, 'P'},
@@ -95,7 +87,7 @@ static option const longopts[] = {
static void printUsage() {
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"
" [-o out_file] [-P include_file] [-p pad_value] [-Q precision]\n"
" [-r depth] [-W warning] [-X max_errors] <file>\n"
@@ -132,10 +124,6 @@ int main(int argc, char *argv[]) {
opt_G("0123");
opt_P(0);
opt_Q(16);
haltNop = false;
warnOnHaltNop = true;
optimizeLoads = false;
warnOnLdOpt = true;
verbose = false;
warnings = true;
sym_SetExportAll(false);
@@ -179,21 +167,6 @@ int main(int argc, char *argv[]) {
errx("Must specify exactly 4 characters for option 'g'");
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
// introduced to better match the `-I dir` option of gcc and clang.
case 'i':
@@ -203,22 +176,6 @@ int main(int argc, char *argv[]) {
fstk_AddIncludePath(musl_optarg);
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':
if (dependFile)
warnx("Overriding dependfile %s", dependFileName);

View File

@@ -21,10 +21,6 @@ struct OptStackEntry {
char gbgfx[4];
uint8_t fixPrecision;
uint8_t fillByte;
bool haltNop;
bool warnOnHaltNop;
bool optimizeLoads;
bool warnOnLdOpt;
bool warningsAreErrors;
size_t maxRecursionDepth;
WarningState warningStates[numWarningStates];
@@ -53,22 +49,6 @@ void opt_R(size_t newDepth) {
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) {
processWarningFlag(flag);
}
@@ -150,34 +130,6 @@ void opt_Parse(char const *s) {
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':
if (strlen(&s[1]) > 0)
opt_W(&s[1]);
@@ -185,42 +137,6 @@ void opt_Parse(char const *s) {
error("Must specify an argument for option 'W'\n");
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:
error("Unknown option '%c'\n", s[0]);
break;
@@ -243,14 +159,6 @@ void opt_Push() {
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
entry.warningsAreErrors = warningsAreErrors;
memcpy(entry.warningStates, warningStates, numWarningStates);
@@ -273,10 +181,6 @@ void opt_Pop() {
opt_G(entry.gbgfx);
opt_P(entry.fillByte);
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_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 {
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);
}
| Z80_LD op_mem_ind COMMA MODE_A {
if (optimizeLoads && $2.isKnown && $2.val >= 0xFF00) {
if (warnOnLdOpt) {
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);
}
sect_AbsByte(0xEA);
sect_RelWord($2, 1);
}
;
@@ -2059,20 +2037,8 @@ z80_ld_a:
}
| Z80_LD reg_r COMMA op_mem_ind {
if ($2 == REG_A) {
if (optimizeLoads && $4.isKnown && $4.val >= 0xFF00) {
if (warnOnLdOpt) {
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);
}
sect_AbsByte(0xFA);
sect_RelWord($4, 1);
} else {
::error("Destination operand must be A\n");
}