Run through clang-format.
This commit is contained in:
parent
671bf250f5
commit
44b6421519
120
util/ego/ic/ic.c
120
util/ego/ic/ic.c
|
@ -29,10 +29,8 @@
|
|||
#include "../share/put.h"
|
||||
#include "../share/aux.h"
|
||||
|
||||
|
||||
/* Global variables */
|
||||
|
||||
|
||||
dblock_p db;
|
||||
dblock_p hol0_db; /* dblock for ABS block */
|
||||
char* curhol; /* name of hol block in current scope */
|
||||
|
@ -54,15 +52,12 @@ lab_id lastlid = 0;
|
|||
offset mespar = UNKNOWN_SIZE;
|
||||
/* argumument of ps_par message of current procedure */
|
||||
|
||||
|
||||
extern process_lines();
|
||||
extern int readline();
|
||||
extern line_p readoperand();
|
||||
extern line_p inpseudo();
|
||||
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
main(argc, argv) int argc;
|
||||
char* argv[];
|
||||
{
|
||||
/* The input files must be legal EM Compact
|
||||
|
@ -83,7 +78,8 @@ main(argc,argv)
|
|||
pdump = openfile(argv[1], "w");
|
||||
ddump = openfile(argv[2], "w");
|
||||
hol0_db = block_of_lab((char*)0);
|
||||
while (next_file(argc,argv) != NULL) {
|
||||
while (next_file(argc, argv) != NULL)
|
||||
{
|
||||
/* Read all EM input files, process the code
|
||||
* and concatenate all output.
|
||||
*/
|
||||
|
@ -104,7 +100,6 @@ main(argc,argv)
|
|||
fclose(pdump);
|
||||
fclose(ddump);
|
||||
|
||||
|
||||
/* remove the remainder of the hashing tables */
|
||||
cleanprocs(prochash, NPROCHASH, 0);
|
||||
cleandblocks(symhash, NSYMHASH, 0);
|
||||
|
@ -116,8 +111,6 @@ main(argc,argv)
|
|||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Value returned by readline */
|
||||
|
||||
#define NORMAL 0
|
||||
|
@ -127,7 +120,6 @@ main(argc,argv)
|
|||
#define END_INSTR 4
|
||||
#define DELETED_INSTR 5
|
||||
|
||||
|
||||
STATIC add_end()
|
||||
{
|
||||
/* Add an end-pseudo to the current instruction list */
|
||||
|
@ -137,7 +129,6 @@ STATIC add_end()
|
|||
lastline->l_instr = ps_end;
|
||||
}
|
||||
|
||||
|
||||
process_lines(fout)
|
||||
FILE* fout;
|
||||
{
|
||||
|
@ -164,9 +155,11 @@ process_lines(fout)
|
|||
eof = FALSE;
|
||||
firstline = (line_p)0;
|
||||
lastline = (line_p)0;
|
||||
while (!eof) {
|
||||
while (!eof)
|
||||
{
|
||||
linecount++; /* for error messages */
|
||||
switch(readline(&instr, &lnp)) {
|
||||
switch (readline(&instr, &lnp))
|
||||
{
|
||||
/* read one line, see what kind it is */
|
||||
case WITH_OPERAND:
|
||||
/* instruction with operand, e.g. LOL 10 */
|
||||
|
@ -175,7 +168,8 @@ process_lines(fout)
|
|||
/* Fall through! */
|
||||
case NORMAL:
|
||||
VL(lnp);
|
||||
if (lastline != (line_p) 0) {
|
||||
if (lastline != (line_p)0)
|
||||
{
|
||||
lastline->l_next = lnp;
|
||||
}
|
||||
lastline = lnp;
|
||||
|
@ -183,7 +177,8 @@ process_lines(fout)
|
|||
case EOFILE:
|
||||
eof = TRUE;
|
||||
fragm_type = DUNKNOWN;
|
||||
if (firstline != (line_p) 0) {
|
||||
if (firstline != (line_p)0)
|
||||
{
|
||||
add_end();
|
||||
putlines(firstline, fout);
|
||||
firstline = (line_p)0;
|
||||
|
@ -192,7 +187,8 @@ process_lines(fout)
|
|||
case PRO_INSTR:
|
||||
VL(lnp);
|
||||
labelcount = 0;
|
||||
if (firstline != lnp) {
|
||||
if (firstline != lnp)
|
||||
{
|
||||
/* If PRO is not the first
|
||||
* instruction:
|
||||
*/
|
||||
|
@ -226,10 +222,7 @@ process_lines(fout)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int readline(instr_out, lnp_out)
|
||||
short *instr_out;
|
||||
int readline(instr_out, lnp_out) short* instr_out;
|
||||
line_p* lnp_out;
|
||||
{
|
||||
register line_p lnp;
|
||||
|
@ -243,7 +236,8 @@ int readline(instr_out, lnp_out)
|
|||
|
||||
VA((short*)instr_out);
|
||||
VA((short*)lnp_out);
|
||||
switch(table1()) {
|
||||
switch (table1())
|
||||
{
|
||||
/* table1 sets string, tabval or tabval2 and
|
||||
* returns an indication of what was read.
|
||||
*/
|
||||
|
@ -262,7 +256,8 @@ int readline(instr_out, lnp_out)
|
|||
SHORT(lnp) = (short)db->d_id;
|
||||
lnp->l_instr = ps_sym;
|
||||
*lnp_out = lnp;
|
||||
if (firstline == (line_p) 0) {
|
||||
if (firstline == (line_p)0)
|
||||
{
|
||||
firstline = lnp;
|
||||
/* only a pseudo (e.g. PRO) or data label
|
||||
* can be the first instruction.
|
||||
|
@ -280,41 +275,45 @@ int readline(instr_out, lnp_out)
|
|||
case PSEU:
|
||||
n = tabval;
|
||||
lnp = inpseudo(n); /* read a pseudo */
|
||||
if (n == ps_hol) n = ps_bss;
|
||||
if (lnp == (line_p) 0) return DELETED_INSTR;
|
||||
if (n == ps_hol)
|
||||
n = ps_bss;
|
||||
if (lnp == (line_p)0)
|
||||
return DELETED_INSTR;
|
||||
*lnp_out = lnp;
|
||||
lnp->l_instr = n;
|
||||
if (firstline == (line_p) 0) {
|
||||
if (firstline == (line_p)0)
|
||||
{
|
||||
firstline = lnp;
|
||||
/* only a pseudo (e.g. PRO) or data label
|
||||
* can be the first instruction.
|
||||
*/
|
||||
}
|
||||
if (n == ps_end) return END_INSTR;
|
||||
if (n == ps_pro) return PRO_INSTR;
|
||||
if (n == ps_end)
|
||||
return END_INSTR;
|
||||
if (n == ps_pro)
|
||||
return PRO_INSTR;
|
||||
return NORMAL;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
|
||||
line_p readoperand(instr)
|
||||
short instr;
|
||||
line_p readoperand(instr) short instr;
|
||||
{
|
||||
/* Read the operand of the given instruction.
|
||||
* Create a line struct and return a pointer to it.
|
||||
*/
|
||||
|
||||
|
||||
register line_p lnp;
|
||||
short flag;
|
||||
|
||||
VI(instr);
|
||||
flag = em_flag[instr - sp_fmnem] & EM_PAR;
|
||||
if (flag == PAR_NO) {
|
||||
if (flag == PAR_NO)
|
||||
{
|
||||
return (newline(OPNO));
|
||||
}
|
||||
switch(table2()) {
|
||||
switch (table2())
|
||||
{
|
||||
case sp_cend:
|
||||
return (newline(OPNO));
|
||||
case CSTX1:
|
||||
|
@ -327,11 +326,11 @@ line_p readoperand(instr)
|
|||
* Similarly, the instruction may have
|
||||
* an instruction label as argument.
|
||||
*/
|
||||
switch(flag) {
|
||||
switch (flag)
|
||||
{
|
||||
case PAR_G:
|
||||
lnp = newline(OPOBJECT);
|
||||
OBJ(lnp) =
|
||||
object(curhol,(offset) tabval,
|
||||
OBJ(lnp) = object(curhol, (offset)tabval,
|
||||
opr_size(instr));
|
||||
break;
|
||||
case PAR_B:
|
||||
|
@ -347,10 +346,10 @@ line_p readoperand(instr)
|
|||
#ifdef LONGOFF
|
||||
case CSTX2:
|
||||
/* double constant */
|
||||
if (flag == PAR_G) {
|
||||
if (flag == PAR_G)
|
||||
{
|
||||
lnp = newline(OPOBJECT);
|
||||
OBJ(lnp) =
|
||||
object(curhol, tabval2,
|
||||
OBJ(lnp) = object(curhol, tabval2,
|
||||
opr_size(instr));
|
||||
break;
|
||||
}
|
||||
|
@ -392,7 +391,6 @@ line_p readoperand(instr)
|
|||
return lnp;
|
||||
}
|
||||
|
||||
|
||||
static char* hol_label()
|
||||
{
|
||||
static int holno;
|
||||
|
@ -409,19 +407,19 @@ static char *hol_label()
|
|||
lnp = newline(OPSHORT);
|
||||
SHORT(lnp) = (short)db->d_id;
|
||||
lnp->l_instr = ps_sym;
|
||||
if (firstline == (line_p) 0) {
|
||||
if (firstline == (line_p)0)
|
||||
{
|
||||
firstline = lnp;
|
||||
}
|
||||
if (lastline != (line_p) 0) {
|
||||
if (lastline != (line_p)0)
|
||||
{
|
||||
lastline->l_next = lnp;
|
||||
}
|
||||
lastline = lnp;
|
||||
return lastname;
|
||||
}
|
||||
|
||||
|
||||
line_p inpseudo(n)
|
||||
short n;
|
||||
line_p inpseudo(n) short n;
|
||||
{
|
||||
int m;
|
||||
line_p lnp;
|
||||
|
@ -436,8 +434,8 @@ line_p inpseudo(n)
|
|||
* be recorded in the datablock or procedure table.
|
||||
*/
|
||||
|
||||
|
||||
switch(n) {
|
||||
switch (n)
|
||||
{
|
||||
case ps_hol:
|
||||
/* hol pseudos are carefully converted into bss
|
||||
* pseudos, so that the IL phase will not be
|
||||
|
@ -445,12 +443,14 @@ line_p inpseudo(n)
|
|||
* block will still work when passed through EGO.
|
||||
*/
|
||||
|
||||
if (lastline != (line_p) 0 && is_datalabel(lastline)) {
|
||||
if (lastline != (line_p)0 && is_datalabel(lastline))
|
||||
{
|
||||
extern char* lastname;
|
||||
|
||||
curhol = lastname;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
curhol = hol_label();
|
||||
}
|
||||
n = ps_bss;
|
||||
|
@ -458,11 +458,12 @@ line_p inpseudo(n)
|
|||
case ps_bss:
|
||||
case ps_rom:
|
||||
case ps_con:
|
||||
if (lastline == (line_p) 0 || !is_datalabel(lastline)) {
|
||||
if (lastline == (line_p)0 || !is_datalabel(lastline))
|
||||
{
|
||||
assert(lastline != (line_p)0);
|
||||
nlast = INSTR(lastline);
|
||||
if (n == nlast &&
|
||||
(n == ps_rom || n == ps_con)) {
|
||||
if (n == nlast && (n == ps_rom || n == ps_con))
|
||||
{
|
||||
/* Two successive roms/cons are
|
||||
* combined into one data block
|
||||
* if the second is not preceded by
|
||||
|
@ -473,7 +474,9 @@ line_p inpseudo(n)
|
|||
combine(db, lastline, lnp, pseu);
|
||||
oldline(lnp);
|
||||
return (line_p)0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
error("datablock without label");
|
||||
}
|
||||
}
|
||||
|
@ -485,12 +488,14 @@ line_p inpseudo(n)
|
|||
*/
|
||||
dblockdef(db, n, lnp);
|
||||
/* Fill in d_pseudo, d_size and d_values fields of db */
|
||||
if (fragm_type != db->d_pseudo) {
|
||||
if (fragm_type != db->d_pseudo)
|
||||
{
|
||||
/* Keep track of fragment numbers,
|
||||
* enter a new fragment.
|
||||
*/
|
||||
fragm_nr++;
|
||||
switch(db->d_pseudo) {
|
||||
switch (db->d_pseudo)
|
||||
{
|
||||
case DCON:
|
||||
case DROM:
|
||||
fragm_type = db->d_pseudo;
|
||||
|
@ -543,7 +548,8 @@ line_p inpseudo(n)
|
|||
return lnp;
|
||||
case ps_mes:
|
||||
lnp = arglist(0);
|
||||
switch((int) aoff(ARG(lnp),0)) {
|
||||
switch ((int)aoff(ARG(lnp), 0))
|
||||
{
|
||||
case ms_err:
|
||||
error("ms_err encountered");
|
||||
case ms_opt:
|
||||
|
|
Loading…
Reference in a new issue