From d716b3376ccf66200d007852b30147ca7f7e7c68 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 3 Sep 2013 16:44:25 -0700 Subject: [PATCH] glsl: Add IR builder support for generating return statements. We use "ret" as the function name since "return" is a C++ keyword, and "ir_return" is already a class name. Signed-off-by: Kenneth Graunke Reviewed-by: Matt Turner Reviewed-by: Paul Berry --- src/glsl/ir_builder.cpp | 7 +++++++ src/glsl/ir_builder.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp index b2b926b610f..b549ff4f72b 100644 --- a/src/glsl/ir_builder.cpp +++ b/src/glsl/ir_builder.cpp @@ -76,6 +76,13 @@ assign(deref lhs, operand rhs, operand condition) return assign(lhs, rhs, condition, (1 << lhs.val->type->vector_elements) - 1); } +ir_return * +ret(operand retval) +{ + void *mem_ctx = ralloc_parent(retval.val); + return new(mem_ctx) ir_return(retval.val); +} + ir_swizzle * swizzle(operand a, int swizzle, int components) { diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h index c852849720f..d423fc5954d 100644 --- a/src/glsl/ir_builder.h +++ b/src/glsl/ir_builder.h @@ -125,6 +125,8 @@ ir_assignment *assign(deref lhs, operand rhs, int writemask); ir_assignment *assign(deref lhs, operand rhs, operand condition); ir_assignment *assign(deref lhs, operand rhs, operand condition, int writemask); +ir_return *ret(operand retval); + ir_expression *expr(ir_expression_operation op, operand a); ir_expression *expr(ir_expression_operation op, operand a, operand b); ir_expression *expr(ir_expression_operation op, operand a, operand b, operand c); -- 2.11.0