@@ -37,13 +37,13 @@ void CodeGenCX86::Visit(const ir::Load *op) {
37
37
38
38
int bits = op->type ().bits () * op->type ().lanes ();
39
39
if (SupportsAVX512 () && bits == 512 ) {
40
- os () << " cinn_avx512_load(" ;
40
+ str_ += " cinn_avx512_load(" ;
41
41
PrintAbsAddr (op);
42
- os () << " )" ;
42
+ str_ += " )" ;
43
43
} else if (SupportsAVX256 () && bits == 256 ) {
44
- os () << " cinn_avx256_load(" ;
44
+ str_ += " cinn_avx256_load(" ;
45
45
PrintAbsAddr (op);
46
- os () << " )" ;
46
+ str_ += " )" ;
47
47
} else {
48
48
CodeGenC::Visit (op);
49
49
}
@@ -57,13 +57,13 @@ void CodeGenCX86::Visit(const ir::Broadcast *op) {
57
57
int bits = op->type ().bits () * op->type ().lanes ();
58
58
59
59
if (SupportsAVX512 () && bits == 512 ) {
60
- os () << " cinn_avx512_set1(" ;
60
+ str_ += " cinn_avx512_set1(" ;
61
61
PrintCastExpr (op->value .type ().ElementOf (), op->value );
62
- os () << " )" ;
62
+ str_ += " )" ;
63
63
} else if (SupportsAVX256 () && bits == 256 ) {
64
- os () << " cinn_avx256_set1(" ;
64
+ str_ += " cinn_avx256_set1(" ;
65
65
PrintCastExpr (op->value .type ().ElementOf (), op->value );
66
- os () << " )" ;
66
+ str_ += " )" ;
67
67
} else {
68
68
CodeGenC::Visit (op);
69
69
}
@@ -77,17 +77,17 @@ void CodeGenCX86::Visit(const ir::Store *op) {
77
77
78
78
int bits = op->type ().bits () * op->type ().lanes ();
79
79
if (SupportsAVX512 () && bits == 512 ) {
80
- os () << " cinn_avx512_store(" ;
80
+ str_ += " cinn_avx512_store(" ;
81
81
PrintAbsAddr (op);
82
- os () << " , " ;
83
- Print (op->value );
84
- os () << " )" ;
82
+ str_ += " , " ;
83
+ IrPrinter::Visit (op->value );
84
+ str_ += " )" ;
85
85
} else if (SupportsAVX256 () && bits == 256 ) {
86
- os () << " cinn_avx256_store(" ;
86
+ str_ += " cinn_avx256_store(" ;
87
87
PrintAbsAddr (op);
88
- os () << " , " ;
89
- Print (op->value );
90
- os () << " )" ;
88
+ str_ += " , " ;
89
+ IrPrinter::Visit (op->value );
90
+ str_ += " )" ;
91
91
} else {
92
92
CodeGenC::Visit (op);
93
93
}
@@ -101,18 +101,18 @@ void CodeGenCX86::PrintVecInputArgument(const Expr *op) {
101
101
Expr value = op->type ().lanes () == 1 ? *op : broadcast_n->value ;
102
102
103
103
if (SupportsAVX512 ()) {
104
- os () << " cinn_avx512_set1(" ;
105
- Print (value);
106
- os () << " )" ;
104
+ str_ += " cinn_avx512_set1(" ;
105
+ IrPrinter::Visit (value);
106
+ str_ += " )" ;
107
107
} else if (SupportsAVX256 ()) {
108
- os () << " cinn_avx256_set1(" ;
109
- Print (value);
110
- os () << " )" ;
108
+ str_ += " cinn_avx256_set1(" ;
109
+ IrPrinter::Visit (value);
110
+ str_ += " )" ;
111
111
} else {
112
112
CINN_NOT_IMPLEMENTED
113
113
}
114
114
} else {
115
- Print (*op);
115
+ IrPrinter::Visit (*op);
116
116
}
117
117
}
118
118
@@ -123,35 +123,41 @@ void CodeGenCX86::Visit(const ir::intrinsics::BuiltinIntrin *op) {
123
123
}
124
124
int bits = op->type ().bits () * op->type ().lanes ();
125
125
if (SupportsAVX512 () && bits == 512 ) {
126
- os () << " cinn_avx512_" << op->name << " (" ;
126
+ str_ += " cinn_avx512_" ;
127
+ str_ += op->name ;
128
+ str_ += " (" ;
127
129
if (!op->args .empty ()) {
128
130
for (int i = 0 ; i < op->args .size () - 1 ; i++) {
129
131
PrintVecInputArgument (&op->args [i]);
130
- os () << " , " ;
132
+ str_ += " , " ;
131
133
}
132
- Print (op->args .back ());
134
+ IrPrinter::Visit (op->args .back ());
133
135
}
134
- os () << " )" ;
136
+ str_ += " )" ;
135
137
} else if (SupportsAVX256 () && bits == 256 ) {
136
- os () << " cinn_avx256_" << op->name << " (" ;
138
+ str_ += " cinn_avx256_" ;
139
+ str_ += op->name ;
140
+ str_ += " (" ;
137
141
if (!op->args .empty ()) {
138
142
for (int i = 0 ; i < op->args .size () - 1 ; i++) {
139
143
PrintVecInputArgument (&op->args [i]);
140
- os () << " , " ;
144
+ str_ += " , " ;
141
145
}
142
146
PrintVecInputArgument (&op->args .back ());
143
147
}
144
- os () << " )" ;
148
+ str_ += " )" ;
145
149
} else if (bits == 128 ) {
146
- os () << " cinn_avx128_" << op->name << " (" ;
150
+ str_ += " cinn_avx128_" ;
151
+ str_ += op->name ;
152
+ str_ += " (" ;
147
153
if (!op->args .empty ()) {
148
154
for (int i = 0 ; i < op->args .size () - 1 ; i++) {
149
155
PrintVecInputArgument (&op->args [i]);
150
- os () << " , " ;
156
+ str_ += " , " ;
151
157
}
152
158
PrintVecInputArgument (&op->args .back ());
153
159
}
154
- os () << " )" ;
160
+ str_ += " )" ;
155
161
} else {
156
162
CodeGenC::Visit (op);
157
163
}
0 commit comments