cubecl_core/ir/
non_semantic.rs1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5use crate::ir::fmt_vararg;
6
7use super::Variable;
8
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
14pub enum NonSemantic {
15 Source {
16 name: String,
17 file_name: String,
18 line: u32,
19 col: u32,
20 },
21 BeginCall {
22 name: String,
23 line: u32,
24 col: u32,
25 },
26 EndCall,
27 Line {
28 line: u32,
29 col: u32,
30 },
31 Print {
32 format_string: String,
33 args: Vec<Variable>,
34 },
35 Comment {
36 content: String,
37 },
38}
39
40impl Display for NonSemantic {
41 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42 match self {
43 NonSemantic::Print {
44 format_string,
45 args,
46 } => {
47 write!(f, "print({format_string}, {})", fmt_vararg(args))
48 }
49 NonSemantic::Comment { content } => write!(f, "//{content}"),
50 _ => {
51 Ok(())
53 }
54 }
55 }
56}