@@ -53,7 +53,7 @@ class CharacterExprHelper {
53
53
54
54
// / Lower \p lhs = \p rhs where \p lhs and \p rhs are scalar characters.
55
55
// / It handles cases where \p lhs and \p rhs may overlap.
56
- void createAssign (mlir::Value lhs, mlir::Value rhs);
56
+ void createAssign (mlir::Value lhs, const fir::ExtendedValue & rhs);
57
57
58
58
// / Lower an assignment where the buffer and LEN parameter are known and do
59
59
// / not need to be unboxed.
@@ -101,7 +101,7 @@ class CharacterExprHelper {
101
101
materializeCharacterOrSequence (mlir::Value str);
102
102
103
103
// / Return true if \p type is a character literal type (is
104
- // / fir.array<len x fir.char<kind>>).;
104
+ // / ` fir.array<len x fir.char<kind>>` ).;
105
105
static bool isCharacterLiteral (mlir::Type type);
106
106
107
107
// / Return true if \p type is one of the following type
@@ -119,6 +119,7 @@ class CharacterExprHelper {
119
119
// / Determine the base character type
120
120
static fir::CharacterType getCharacterType (mlir::Type type);
121
121
static fir::CharacterType getCharacterType (const fir::CharBoxValue &box);
122
+ static fir::CharacterType getCharacterType (mlir::Value str);
122
123
123
124
// / Return the integer type that must be used to manipulate
124
125
// / Character lengths. TODO: move this to FirOpBuilder?
@@ -130,10 +131,12 @@ class CharacterExprHelper {
130
131
// / - fir.array<len x fir.char<kind>>
131
132
// / - fir.char<kind>
132
133
// / - fir.ref<char<kind>>
133
- // / If the no length is passed, it is attempted to be extracted from \p
134
- // / character (or its type). This will crash if this is not possible.
135
- // / The returned value is a CharBoxValue if \p character is a scalar,
136
- // / otherwise it is a CharArrayBoxValue.
134
+ // /
135
+ // / Does the heavy lifting of converting the value \p character (along with an
136
+ // / optional \p len value) to an extended value. If \p len is null, a length
137
+ // / value is extracted from \p character (or its type). This will produce an
138
+ // / error if it's not possible. The returned value is a CharBoxValue if \p
139
+ // / character is a scalar, otherwise it is a CharArrayBoxValue.
137
140
fir::ExtendedValue toExtendedValue (mlir::Value character,
138
141
mlir::Value len = {});
139
142
@@ -143,17 +146,23 @@ class CharacterExprHelper {
143
146
// / - !fir.array<dim x !fir.char<kind, len>>
144
147
// / - !fir.ref<T> where T is either of the first two cases
145
148
// / - !fir.box<T> where T is either of the first two cases
149
+ // /
150
+ // / In certain contexts, Fortran allows an array of CHARACTERs to be treated
151
+ // / as if it were one longer CHARACTER scalar, each element append to the
152
+ // / previous.
146
153
static bool isArray (mlir::Type type);
147
154
148
155
private:
149
- fir::CharBoxValue materializeValue (const fir::CharBoxValue & str);
156
+ fir::CharBoxValue materializeValue (mlir::Value str);
150
157
fir::CharBoxValue toDataLengthPair (mlir::Value character);
151
158
mlir::Type getReferenceType (const fir::CharBoxValue &c) const ;
159
+ mlir::Type getReferenceType (mlir::Value str) const ;
152
160
mlir::Type getSeqTy (const fir::CharBoxValue &c) const ;
161
+ mlir::Type getSeqTy (mlir::Value str) const ;
162
+ mlir::Value getCharBoxBuffer (const fir::CharBoxValue &box);
153
163
mlir::Value createEmbox (const fir::CharBoxValue &str);
154
- mlir::Value createLoadCharAt (const fir::CharBoxValue &str, mlir::Value index);
155
- void createStoreCharAt (const fir::CharBoxValue &str, mlir::Value index,
156
- mlir::Value c);
164
+ mlir::Value createLoadCharAt (mlir::Value buff, mlir::Value index);
165
+ void createStoreCharAt (mlir::Value str, mlir::Value index, mlir::Value c);
157
166
void createCopy (const fir::CharBoxValue &dest, const fir::CharBoxValue &src,
158
167
mlir::Value count);
159
168
void createPadding (const fir::CharBoxValue &str, mlir::Value lower,
0 commit comments