Expand description
§OpenMP Intermediate Representation (IR)
This module provides a semantic representation of OpenMP directives and clauses. Unlike the parser module which deals with syntax, the IR focuses on the meaning of the parsed constructs.
§Design Philosophy
The IR layer serves as a bridge between the parser (syntax) and compilers (semantics):
Input String → Parser → Directive (syntax) → IR → DirectiveIR (semantics) → Compiler
§Key Differences: Parser vs IR
Aspect | Parser | IR |
---|---|---|
Focus | Syntax preservation | Semantic meaning |
Clause data | "private(a, b)" as string | List of identifiers ["a", "b"] |
Expressions | Unparsed strings | Optionally parsed AST |
Validation | Minimal | Comprehensive |
Use case | Parsing | Compilation, analysis |
§Learning Path
This module is designed to teach Rust concepts incrementally:
- Basic types: Structs, enums, Copy trait
- Advanced enums: Enums with data, pattern matching
- Lifetime management: References, ownership
- Trait implementation: Display, conversion traits
- Error handling: Result types, custom errors
- FFI preparation: repr(C), opaque types
§Module Organization
types
: Basic types (SourceLocation, Language, etc.)expression
: Expression representation (parsed or unparsed)clause_data
: Semantic clause data structuresdirective_ir
: Complete directive representationconversion
: Convert parser types to IRdisplay
: Pretty-printing IR back to pragmas
Re-exports§
pub use convert::ConversionError;
pub use validate::ValidationContext;
pub use validate::ValidationError;
Modules§
Structs§
- Array
Section - Array section specification:
[lower:length:stride]
- Directive
Builder - Builder for constructing DirectiveIR with a fluent API
- DirectiveIR
- Complete IR representation of an OpenMP directive
- Expression
Ast - Parsed expression abstract syntax tree
- Identifier
- A simple identifier (not an expression, not a variable with sections)
- Parser
Config - Configuration for IR generation and expression parsing
- Source
Location - Source code location information
- Variable
- A variable reference, possibly with array sections
Enums§
- Atomic
Op - Atomic operation type
- Binary
Operator - Binary operators
- Clause
Data - Complete semantic data for an OpenMP clause
- Clause
Item - Item that can appear in a clause list
- Default
Kind - Default data-sharing attribute
- Depend
Type - Dependence type for task dependencies
- Device
Type - Device type for device-specific constructs
- Directive
Kind - OpenMP directive type
- Expression
- An expression that may be parsed or unparsed
- Expression
Kind - Common expression patterns in OpenMP directives
- Language
- Source programming language
- Lastprivate
Modifier - Lastprivate clause modifier
- Linear
Modifier - Linear clause modifier
- MapType
- Map type for map clauses in target directives
- Memory
Order - Default memory order for atomic operations
- Order
Kind - Order clause value
- Proc
Bind - Thread affinity policy
- Reduction
Operator - Reduction operator for reduction clauses
- Schedule
Kind - Schedule kind for loop scheduling
- Schedule
Modifier - Schedule modifier for schedule clause
- Unary
Operator - Unary operators