Enum ClauseData

Source
pub enum ClauseData {
Show 43 variants Bare(Identifier), Expression(Expression), ItemList(Vec<ClauseItem>), Private { items: Vec<ClauseItem>, }, Firstprivate { items: Vec<ClauseItem>, }, Lastprivate { modifier: Option<LastprivateModifier>, items: Vec<ClauseItem>, }, Shared { items: Vec<ClauseItem>, }, Default(DefaultKind), Reduction { operator: ReductionOperator, items: Vec<ClauseItem>, }, Map { map_type: Option<MapType>, mapper: Option<Identifier>, items: Vec<ClauseItem>, }, UseDevicePtr { items: Vec<ClauseItem>, }, UseDeviceAddr { items: Vec<ClauseItem>, }, IsDevicePtr { items: Vec<ClauseItem>, }, HasDeviceAddr { items: Vec<ClauseItem>, }, Depend { depend_type: DependType, items: Vec<ClauseItem>, }, Priority { priority: Expression, }, Affinity { items: Vec<ClauseItem>, }, Schedule { kind: ScheduleKind, modifiers: Vec<ScheduleModifier>, chunk_size: Option<Expression>, }, Collapse { n: Expression, }, Ordered { n: Option<Expression>, }, Linear { modifier: Option<LinearModifier>, items: Vec<ClauseItem>, step: Option<Expression>, }, Aligned { items: Vec<ClauseItem>, alignment: Option<Expression>, }, Safelen { length: Expression, }, Simdlen { length: Expression, }, If { directive_name: Option<Identifier>, condition: Expression, }, ProcBind(ProcBind), NumThreads { num: Expression, }, Device { device_num: Expression, }, DeviceType(DeviceType), AtomicDefaultMemOrder(MemoryOrder), AtomicOperation { op: AtomicOp, memory_order: Option<MemoryOrder>, }, Order(OrderKind), NumTeams { num: Expression, }, ThreadLimit { limit: Expression, }, Allocate { allocator: Option<Identifier>, items: Vec<ClauseItem>, }, Allocator { allocator: Identifier, }, Copyin { items: Vec<ClauseItem>, }, Copyprivate { items: Vec<ClauseItem>, }, DistSchedule { kind: ScheduleKind, chunk_size: Option<Expression>, }, Grainsize { grain: Expression, }, NumTasks { num: Expression, }, Filter { thread_num: Expression, }, Generic { name: Identifier, data: Option<String>, },
}
Expand description

Complete semantic data for an OpenMP clause

This enum represents the meaning of each OpenMP clause type. Each variant captures the specific data needed for that clause.

§Examples

// default(shared)
let clause = ClauseData::Default(DefaultKind::Shared);
assert_eq!(clause.to_string(), "default(shared)");

// reduction(+: sum)
let clause = ClauseData::Reduction {
    operator: ReductionOperator::Add,
    items: vec![Identifier::new("sum").into()],
};
assert_eq!(clause.to_string(), "reduction(+: sum)");

§Learning: Large Enums with Complex Data

This enum demonstrates several advanced Rust patterns:

  1. Many variants: ~30 variants for different clause types
  2. Variants with data: Most variants contain structured data
  3. Named fields: Using struct-like syntax for clarity
  4. Vec for lists: Variable-length lists of items
  5. Option for optionals: Optional parameters
  6. Composition: Combines all previous IR types

§Design Philosophy

Each variant captures exactly what’s needed for semantic analysis:

  • Private: List of variables to make private
  • Reduction: Operator + list of reduction variables
  • Map: Map type + list of variables to map
  • Schedule: Schedule kind + optional modifiers + optional chunk size

This is much richer than the parser’s string-based representation.

Variants§

§

Bare(Identifier)

Clause with no parameters (e.g., nowait, nogroup)

§

Expression(Expression)

Single expression parameter (e.g., num_threads(4))

§

ItemList(Vec<ClauseItem>)

List of items (e.g., private(x, y, z))

§

Private

private(list) - Variables are private to each thread

Fields

§

Firstprivate

firstprivate(list) - Variables initialized from master thread

Fields

§

Lastprivate

lastprivate([modifier:] list) - Variables updated from last iteration

§

Shared

shared(list) - Variables shared among all threads

Fields

§

Default(DefaultKind)

default(shared|none|...) - Default data-sharing attribute

§

Reduction

reduction([modifier,]operator: list) - Reduction operation

Fields

§

Map

map([[mapper(id),] map-type:] list) - Map variables to device

Fields

§map_type: Option<MapType>
§

UseDevicePtr

use_device_ptr(list) - Use device pointers

Fields

§

UseDeviceAddr

use_device_addr(list) - Use device addresses

Fields

§

IsDevicePtr

is_device_ptr(list) - Variables are device pointers

Fields

§

HasDeviceAddr

has_device_addr(list) - Variables have device addresses

Fields

§

Depend

depend([modifier,] type: list) - Task dependencies

Fields

§depend_type: DependType
§

Priority

priority(expression) - Task priority

Fields

§priority: Expression
§

Affinity

affinity([modifier:] list) - Task affinity

Fields

§

Schedule

schedule([modifier [, modifier]:]kind[, chunk_size]) - Loop schedule

Fields

§chunk_size: Option<Expression>
§

Collapse

collapse(n) - Collapse nested loops

Fields

§

Ordered

ordered[(n)] - Ordered iterations

§

Linear

linear(list[:step]) - Linear variables in SIMD

§

Aligned

aligned(list[:alignment]) - Aligned variables

Fields

§alignment: Option<Expression>
§

Safelen

safelen(length) - Safe SIMD vector length

Fields

§length: Expression
§

Simdlen

simdlen(length) - Preferred SIMD vector length

Fields

§length: Expression
§

If

if([directive-name-modifier:] expression) - Conditional execution

Fields

§directive_name: Option<Identifier>
§condition: Expression
§

ProcBind(ProcBind)

proc_bind(master|close|spread|primary) - Thread affinity policy

§

NumThreads

num_threads(expression) - Number of threads

Fields

§

Device

device(expression) - Target device

Fields

§device_num: Expression
§

DeviceType(DeviceType)

device_type(host|nohost|any) - Device type specifier

§

AtomicDefaultMemOrder(MemoryOrder)

atomic_default_mem_order(seq_cst|acq_rel|...) - Default memory order

§

AtomicOperation

Atomic operation modifier

Fields

§memory_order: Option<MemoryOrder>
§

Order(OrderKind)

order(concurrent) - Iteration execution order

§

NumTeams

num_teams(expression) - Number of teams

Fields

§

ThreadLimit

thread_limit(expression) - Thread limit per team

Fields

§

Allocate

allocate([allocator:] list) - Memory allocator

Fields

§allocator: Option<Identifier>
§

Allocator

allocator(allocator-handle) - Specify allocator

Fields

§allocator: Identifier
§

Copyin

copyin(list) - Copy master thread value to team threads

Fields

§

Copyprivate

copyprivate(list) - Broadcast value from one thread

Fields

§

DistSchedule

dist_schedule(kind[, chunk_size]) - Distribute schedule

Fields

§chunk_size: Option<Expression>
§

Grainsize

grainsize(expression) - Taskloop grainsize

Fields

§

NumTasks

num_tasks(expression) - Number of tasks

Fields

§

Filter

filter(thread-num) - Thread filter for masked construct

Fields

§thread_num: Expression
§

Generic

Generic clause with unparsed data (fallback for unknown clauses)

Fields

Implementations§

Source§

impl<'a> ClauseData

Source

pub fn is_default(&self) -> bool

Check if this is a default clause

Source

pub fn is_private(&self) -> bool

Check if this is a private clause

Source

pub fn is_firstprivate(&self) -> bool

Check if this is a firstprivate clause

Source

pub fn is_lastprivate(&self) -> bool

Check if this is a lastprivate clause

Source

pub fn is_shared(&self) -> bool

Check if this is a shared clause

Source

pub fn is_reduction(&self) -> bool

Check if this is a reduction clause

Source

pub fn is_map(&self) -> bool

Check if this is a map clause

Source

pub fn is_if(&self) -> bool

Check if this is an if clause

Source

pub fn is_num_threads(&self) -> bool

Check if this is a num_threads clause

Source

pub fn is_collapse(&self) -> bool

Check if this is a collapse clause

Source

pub fn is_ordered(&self) -> bool

Check if this is an ordered clause

Source

pub fn is_schedule(&self) -> bool

Check if this is a schedule clause

Source

pub fn is_device(&self) -> bool

Check if this is a device clause

Source

pub fn is_depend(&self) -> bool

Check if this is a depend clause

Source

pub fn is_linear(&self) -> bool

Check if this is a linear clause

Source

pub fn is_proc_bind(&self) -> bool

Check if this is a proc_bind clause

Trait Implementations§

Source§

impl Clone for ClauseData

Source§

fn clone(&self) -> ClauseData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClauseData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ClauseData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ClauseData

Source§

fn eq(&self, other: &ClauseData) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ClauseData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.