Module ir

Source
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

AspectParserIR
FocusSyntax preservationSemantic meaning
Clause data"private(a, b)" as stringList of identifiers ["a", "b"]
ExpressionsUnparsed stringsOptionally parsed AST
ValidationMinimalComprehensive
Use caseParsingCompilation, analysis

§Learning Path

This module is designed to teach Rust concepts incrementally:

  1. Basic types: Structs, enums, Copy trait
  2. Advanced enums: Enums with data, pattern matching
  3. Lifetime management: References, ownership
  4. Trait implementation: Display, conversion traits
  5. Error handling: Result types, custom errors
  6. 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 structures
  • directive_ir: Complete directive representation
  • conversion: Convert parser types to IR
  • display: Pretty-printing IR back to pragmas

Re-exports§

pub use convert::ConversionError;
pub use validate::ValidationContext;
pub use validate::ValidationError;

Modules§

convert
Conversion from parser types to IR types
validate
IR validation utilities

Structs§

ArraySection
Array section specification: [lower:length:stride]
DirectiveBuilder
Builder for constructing DirectiveIR with a fluent API
DirectiveIR
Complete IR representation of an OpenMP directive
ExpressionAst
Parsed expression abstract syntax tree
Identifier
A simple identifier (not an expression, not a variable with sections)
ParserConfig
Configuration for IR generation and expression parsing
SourceLocation
Source code location information
Variable
A variable reference, possibly with array sections

Enums§

AtomicOp
Atomic operation type
BinaryOperator
Binary operators
ClauseData
Complete semantic data for an OpenMP clause
ClauseItem
Item that can appear in a clause list
DefaultKind
Default data-sharing attribute
DependType
Dependence type for task dependencies
DeviceType
Device type for device-specific constructs
DirectiveKind
OpenMP directive type
Expression
An expression that may be parsed or unparsed
ExpressionKind
Common expression patterns in OpenMP directives
Language
Source programming language
LastprivateModifier
Lastprivate clause modifier
LinearModifier
Linear clause modifier
MapType
Map type for map clauses in target directives
MemoryOrder
Default memory order for atomic operations
OrderKind
Order clause value
ProcBind
Thread affinity policy
ReductionOperator
Reduction operator for reduction clauses
ScheduleKind
Schedule kind for loop scheduling
ScheduleModifier
Schedule modifier for schedule clause
UnaryOperator
Unary operators