diff options
author | Quentin Carbonneaux <quentin@c9x.me> | 2022-11-22 21:44:44 +0100 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2022-11-22 21:56:21 +0100 |
commit | cbee74bdb4f85d6d8d4f192f0018ea023418e216 (patch) | |
tree | 4ea3eb41265e44336d81fecf719193c67540f3d3 /all.h | |
parent | 04e26409011389f7b5759114905195a4fb0b0286 (diff) | |
download | roux-cbee74bdb4f85d6d8d4f192f0018ea023418e216.tar.gz |
use a new struct for symbols
Symbols are a useful abstraction that occurs in both Con and Alias. In this patch they get their own struct. This new struct packages a symbol name and a type; the type tells us where the symbol name must be interpreted (currently, in gobal memory or in thread-local storage). The refactor fixed a bug in addcon(), proving the value of packaging symbol names with their type.
Diffstat (limited to 'all.h')
-rw-r--r-- | all.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/all.h b/all.h index 00b8628..d852609 100644 --- a/all.h +++ b/all.h @@ -20,6 +20,7 @@ typedef struct Ins Ins; typedef struct Phi Phi; typedef struct Blk Blk; typedef struct Use Use; +typedef struct Sym Sym; typedef struct Alias Alias; typedef struct Tmp Tmp; typedef struct Con Con; @@ -264,6 +265,14 @@ struct Use { } u; }; +struct Sym { + enum { + SGlo, + SThr, + } type; + uint32_t id; +}; + enum { NoAlias, MayAlias, @@ -283,10 +292,7 @@ struct Alias { int base; int64_t offset; union { - struct { - uint32_t label; - int con; - } sym; + Sym sym; struct { int sz; /* -1 if > NBit */ bits m; @@ -329,16 +335,12 @@ struct Con { CBits, CAddr, } type; - uint32_t label; + Sym sym; union { int64_t i; double d; float s; } bits; - enum { - RelDef, - RelThr, - } reloc; char flt; /* 1 to print as s, 2 to print as d */ }; @@ -463,6 +465,7 @@ int clsmerge(short *, short); int phicls(int, Tmp *); Ref newtmp(char *, int, Fn *); void chuse(Ref, int, Fn *); +int symeq(Sym, Sym); Ref newcon(Con *, Fn *); Ref getcon(int64_t, Fn *); int addcon(Con *, Con *); |