Lines Matching defs:constant

291     // the location being accessed is "constant" (see for details:
801 /// Returns an integer or float attribute for the provided scalar constant
831 /// Returns an integer or float attribute array for the provided constant
845 Attribute ModuleImport::getConstantAsAttr(llvm::Constant *constant) {
847 if (Attribute scalarAttr = getScalarConstantAsAttr(builder, constant))
856 // Convert one-dimensional constant arrays or vectors that store 1/2/4/8-byte
858 if (auto *constArray = dyn_cast<llvm::ConstantDataSequential>(constant)) {
865 auto *constVector = dyn_cast<llvm::ConstantDataVector>(constant);
878 // Convert multi-dimensional constant aggregates that store all kinds of
880 if (auto *constAggregate = dyn_cast<llvm::ConstantAggregate>(constant)) {
897 // Append the elements of nested constant arrays or vectors that store
911 // Bail if the aggregate contains a unsupported constant type such as a
912 // constant expression.
919 if (auto *constZero = dyn_cast<llvm::ConstantAggregateZero>(constant)) {
1071 ModuleImport::getConstantsToConvert(llvm::Constant *constant) {
1072 // Return the empty set if the constant has been translated before.
1073 if (valueMapping.contains(constant))
1076 // Traverse the constants in post-order and stop the traversal if a constant
1077 // already has a `valueMapping` from an earlier constant translation or if the
1078 // constant is traversed a second time.
1082 workList.insert(constant);
1093 // Collect all dependencies of the current constant and add them to the
1097 // Add all constant operands to the adjacency list and skip any other
1110 // Add the current constant to the `orderedSet` of the traversed nodes if
1112 // constant from the `workList` and continue the traversal.
1133 FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
1137 if (Attribute attr = getConstantAsAttr(constant)) {
1138 Type type = convertType(constant->getType());
1147 if (auto *nullPtr = dyn_cast<llvm::ConstantPointerNull>(constant)) {
1153 if (isa<llvm::ConstantTokenNone>(constant)) {
1158 if (auto *poisonVal = dyn_cast<llvm::PoisonValue>(constant)) {
1164 if (auto *undefVal = dyn_cast<llvm::UndefValue>(constant)) {
1170 if (auto *globalObj = dyn_cast<llvm::GlobalObject>(constant)) {
1183 // Convert constant expressions.
1184 if (auto *constExpr = dyn_cast<llvm::ConstantExpr>(constant)) {
1185 // Convert the constant expression to a temporary LLVM instruction and
1193 "expected constant expression to return a result");
1198 // since all constant dependencies have been converted before.
1208 if (isa<llvm::ConstantAggregate>(constant) ||
1209 isa<llvm::ConstantAggregateZero>(constant)) {
1212 if (auto *constAgg = dyn_cast<llvm::ConstantAggregate>(constant)) {
1217 if (auto *constAgg = dyn_cast<llvm::ConstantAggregateZero>(constant)) {
1227 Type rootType = convertType(constant->getType());
1246 if (auto *constTargetNone = dyn_cast<llvm::ConstantTargetNone>(constant)) {
1257 if (isa<llvm::BlockAddress>(constant))
1260 return emitError(loc) << "unhandled constant: " << diag(*constant) << error;
1263 FailureOr<Value> ModuleImport::convertConstantExpr(llvm::Constant *constant) {
1265 // since it updates the constant insertion point assuming the converted
1266 // constant has been introduced at the end of the constant section.
1267 assert(!valueMapping.contains(constant) &&
1268 "expected constant has not been converted before");
1270 "expected the constant insertion block to be non-null");
1272 // Insert the constant after the last one or at the start of the entry block.
1281 getConstantsToConvert(constant);
1289 // Update the constant insertion point and return the converted constant.
1290 Value result = lookupValue(constant);
1305 if (auto *constant = dyn_cast<llvm::Constant>(value))
1306 return convertConstantExpr(constant);
1331 if (auto *constant = dyn_cast<llvm::Constant>(value))
1332 return convertConstantExpr(constant);
1362 auto *constant = llvm::cast<llvm::Constant>(value);
1363 auto attr = getScalarConstantAsAttr(builder, constant);
1365 "expected immarg to be float or integer constant");
1418 assert(success && "expected a constant integer value");
1428 assert(success && "expected a constant float value");
1503 // treated as indirect calls to constant operands that need to be converted.
1774 // approach is that many unused `llvm.mlir.constant` would be emitted