roup/ir/
mod.rs

1//! # OpenMP Intermediate Representation (IR)
2//!
3//! This module provides a **semantic** representation of OpenMP directives and clauses.
4//! Unlike the parser module which deals with syntax, the IR focuses on the **meaning**
5//! of the parsed constructs.
6//!
7//! ## Design Philosophy
8//!
9//! The IR layer serves as a bridge between the parser (syntax) and compilers (semantics):
10//!
11//! ```text
12//! Input String → Parser → Directive (syntax) → IR → DirectiveIR (semantics) → Compiler
13//! ```
14//!
15//! ## Key Differences: Parser vs IR
16//!
17//! | Aspect | Parser | IR |
18//! |--------|--------|-----|
19//! | **Focus** | Syntax preservation | Semantic meaning |
20//! | **Clause data** | `"private(a, b)"` as string | List of identifiers `["a", "b"]` |
21//! | **Expressions** | Unparsed strings | Optionally parsed AST |
22//! | **Validation** | Minimal | Comprehensive |
23//! | **Use case** | Parsing | Compilation, analysis |
24//!
25//! ## Learning Path
26//!
27//! This module is designed to teach Rust concepts incrementally:
28//!
29//! 1. **Basic types**: Structs, enums, Copy trait
30//! 2. **Advanced enums**: Enums with data, pattern matching
31//! 3. **Lifetime management**: References, ownership
32//! 4. **Trait implementation**: Display, conversion traits
33//! 5. **Error handling**: Result types, custom errors
34//! 6. **FFI preparation**: repr(C), opaque types
35//!
36//! ## Module Organization
37//!
38//! - `types`: Basic types (SourceLocation, Language, etc.)
39//! - `expression`: Expression representation (parsed or unparsed)
40//! - `clause_data`: Semantic clause data structures
41//! - `directive_ir`: Complete directive representation
42//! - `conversion`: Convert parser types to IR
43//! - `display`: Pretty-printing IR back to pragmas
44
45// Re-export main types
46pub use builder::DirectiveBuilder;
47pub use clause::{
48    AtomicOp, ClauseData, ClauseItem, DefaultKind, DependType, DeviceType, LastprivateModifier,
49    LinearModifier, MapType, MemoryOrder, OrderKind, ProcBind, ReductionOperator, ScheduleKind,
50    ScheduleModifier,
51};
52pub use convert::ConversionError;
53pub use directive::{DirectiveIR, DirectiveKind};
54pub use expression::{
55    BinaryOperator, Expression, ExpressionAst, ExpressionKind, ParserConfig, UnaryOperator,
56};
57pub use types::{Language, SourceLocation};
58pub use validate::{ValidationContext, ValidationError};
59pub use variable::{ArraySection, Identifier, Variable};
60
61mod builder;
62mod clause;
63pub mod convert;
64mod directive;
65mod expression;
66mod types;
67pub mod validate;
68mod variable;