-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a simplified C IR. #253
Comments
Normalizing data declarations sounds good. For name mangling, we need to make sure that the IR has the necessary context. For example, the context for an anonymous Example: typedef struct rect {
struct { int x; int y; } tl;
struct { int x; int y; } br;
} rect; IR sketch: struct ir::anonymous<rect, tl> {
int x;
int y;
};
struct ir::anonymous<rect, br> {
int x;
int y;
};
struct ir::struct<rect> {
struct ir::anonymous<rect, tl> tl;
struct ir::anonymous<rect, br> br;
};
typedef ir::struct<rect> rect; Haskell with default optionsdata CRectTl = MkCRectTl {
cRectTlX :: Int
, cRectTlY :: Int
}
data CRectBr = MkCRectBr {
cRectBrX :: Int
, cRectBrY :: Int
}
data CRect = MkCRect {
cRectTl :: CRectTl
, cRectBr :: CRectBr
} By the way, I am about to implement a change to name mangling that should make it easier to use due to improved organization and documentation. |
Yes, this sounds completely reasonable to me. I wonder if we can the AST annotations (#256) to provide some additional guarantees which kinds of simplications have taken place? |
Why? |
So that subsequent passes can depend on it....? |
I assume you meant that we'd use same types for input C and simplified IR. I'm against that. They are different enough that having separate structures is a lot cleaner, than trying to be clever how to not duplicate stuff. |
Oh, I see. |
Kind of done in #295 |
When working with data declarations recently, I stumble all the time on "complexity" of C. For example
works. There
typedef
declaration is two-in-one:For humans the two-in-one notion maybe handy; but for code-processing having simpler blocks is... simpler.
So I suggest that we introduce a simplified C IR, elaborating some compound C declarations into simpler ones.
To continue an example, I'd argue that even
is easier to process as (in pseudo-C)
and similar transformations may applied to "flatten" nested structs and unions.
The text was updated successfully, but these errors were encountered: