================
@@ -1564,7 +1660,103 @@ bool IRInterpreter::Interpret(llvm::Module &module,
llvm::Function &function,
returnVal = value.GetScalar();
// Push the return value as the result
- frame.AssignValue(inst, returnVal, module);
+ frame.AssignValue(inst, returnVal, module, exe_ctx);
+ }
+ } break;
+ case Instruction::ExtractElement: {
+ const ExtractElementInst *extract_inst = cast<ExtractElementInst>(inst);
+
+ // Get the vector and index operands
+ const Value *vector_operand = extract_inst->getVectorOperand();
+ const Value *index_operand = extract_inst->getIndexOperand();
+
+ // Get the vector address
+ lldb::addr_t vector_addr =
+ frame.ResolveValue(vector_operand, module, exe_ctx);
+
+ if (vector_addr == LLDB_INVALID_ADDRESS) {
+ LLDB_LOGF(log, "ExtractElement's vector doesn't resolve to anything");
+ error = lldb_private::Status::FromErrorString(bad_value_error);
+ return false;
+ }
+
+ // Evaluate the index
+ lldb_private::Scalar index_scalar;
+ if (!frame.EvaluateValue(index_scalar, index_operand, module, exe_ctx)) {
+ LLDB_LOGF(log, "Couldn't evaluate index %s",
+ PrintValue(index_operand).c_str());
+ error = lldb_private::Status::FromErrorString(bad_value_error);
+ return false;
+ }
+
+ uint64_t index = index_scalar.ULongLong();
+
+ // Get the vector type information
+ auto *vector_type = dyn_cast<FixedVectorType>(vector_operand->getType());
+ if (!vector_type) {
+ LLDB_LOGF(log, "ExtractElement instruction doesn't have a fixed vector
"
+ "operand type");
+ error =
+ lldb_private::Status::FromErrorString(interpreter_internal_error);
+ return false;
+ }
+
+ unsigned num_elements = vector_type->getNumElements();
+ if (index >= num_elements) {
+ LLDB_LOGF(log,
+ "ExtractElement index %llu is out of bounds for vector with "
+ "%u elements",
+ (unsigned long long)index, num_elements);
----------------
Michael137 wrote:
```suggestion
LLDB_LOG(log,
"ExtractElement index {0} is out of bounds for vector with "
"{1} elements",
index, num_elements);
```
https://github.com/llvm/llvm-project/pull/155000
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits