[Bf-blender-cvs] [b7bb0a0] object_nodes: Cleanup: use argument pointers for aggregate base types.

Lukas Tönne noreply at git.blender.org
Sat May 28 11:31:01 CEST 2016


Commit: b7bb0a0c4d76dce4caa7722cf7439362f090c622
Author: Lukas Tönne
Date:   Fri May 27 17:20:52 2016 +0200
Branches: object_nodes
https://developer.blender.org/rBb7bb0a0c4d76dce4caa7722cf7439362f090c622

Cleanup: use argument pointers for aggregate base types.

===================================================================

M	source/blender/blenvm/compile/typedesc.cc
M	source/blender/blenvm/compile/typedesc.h
M	source/blender/blenvm/llvm/llvm_compiler_dual.cc
M	source/blender/blenvm/llvm/llvm_compiler_simple.cc

===================================================================

diff --git a/source/blender/blenvm/compile/typedesc.cc b/source/blender/blenvm/compile/typedesc.cc
index a599306..3348243 100644
--- a/source/blender/blenvm/compile/typedesc.cc
+++ b/source/blender/blenvm/compile/typedesc.cc
@@ -172,6 +172,24 @@ bool TypeSpec::operator < (const TypeSpec &other) const
 	}
 }
 
+bool TypeSpec::is_aggregate() const
+{
+	switch (m_base_type) {
+		case BVM_FLOAT:
+		case BVM_INT:
+			return false;
+		case BVM_FLOAT3:
+		case BVM_FLOAT4:
+		case BVM_MATRIX44:
+		case BVM_STRING:
+		case BVM_RNAPOINTER:
+		case BVM_MESH:
+		case BVM_DUPLIS:
+			return true;
+	}
+	return false;
+}
+
 bool TypeSpec::assignable(const TypeSpec &other) const
 {
 	return *this == other;
diff --git a/source/blender/blenvm/compile/typedesc.h b/source/blender/blenvm/compile/typedesc.h
index 94a90b4..b9fd6d1 100644
--- a/source/blender/blenvm/compile/typedesc.h
+++ b/source/blender/blenvm/compile/typedesc.h
@@ -180,6 +180,7 @@ struct TypeSpec {
 	
 	BVMType base_type() const { return m_base_type; }
 	BVMBufferType buffer_type() const { return m_buffer_type; }
+	bool is_aggregate() const;
 	
 	bool assignable(const TypeSpec &other) const;
 	
diff --git a/source/blender/blenvm/llvm/llvm_compiler_dual.cc b/source/blender/blenvm/llvm/llvm_compiler_dual.cc
index 83921c6..0c63128 100644
--- a/source/blender/blenvm/llvm/llvm_compiler_dual.cc
+++ b/source/blender/blenvm/llvm/llvm_compiler_dual.cc
@@ -59,35 +59,17 @@ bool LLVMTextureCompiler::use_argument_pointer(const TypeSpec *typespec, bool is
 {
 	using namespace llvm;
 	
-	if (typespec->is_structure()) {
+	if (!is_constant && bvm_type_has_dual_value(typespec)) {
 		/* pass by reference */
 		return true;
 	}
-	else if (!is_constant && bvm_type_has_dual_value(typespec)) {
+	else if (typespec->is_aggregate() || typespec->is_structure()) {
+		/* pass by reference */
 		return true;
 	}
 	else {
-		switch (typespec->base_type()) {
-			case BVM_FLOAT:
-			case BVM_INT:
-				/* pass by value */
-				return false;
-			case BVM_FLOAT3:
-			case BVM_FLOAT4:
-			case BVM_MATRIX44:
-				/* pass by reference */
-				return true;
-				
-			case BVM_STRING:
-			case BVM_RNAPOINTER:
-			case BVM_MESH:
-			case BVM_DUPLIS:
-				/* TODO */
-				break;
-		}
+		return false;
 	}
-	
-	return false;
 }
 
 bool LLVMTextureCompiler::use_elementary_argument_pointer(const TypeSpec *typespec)
diff --git a/source/blender/blenvm/llvm/llvm_compiler_simple.cc b/source/blender/blenvm/llvm/llvm_compiler_simple.cc
index eb608d7..a197eab 100644
--- a/source/blender/blenvm/llvm/llvm_compiler_simple.cc
+++ b/source/blender/blenvm/llvm/llvm_compiler_simple.cc
@@ -59,32 +59,13 @@ bool LLVMSimpleCompilerImpl::use_argument_pointer(const TypeSpec *typespec, bool
 {
 	using namespace llvm;
 	
-	if (typespec->is_structure()) {
+	if (typespec->is_aggregate() || typespec->is_structure()) {
 		/* pass by reference */
 		return true;
 	}
 	else {
-		switch (typespec->base_type()) {
-			case BVM_FLOAT:
-			case BVM_INT:
-				/* pass by value */
-				return false;
-			case BVM_FLOAT3:
-			case BVM_FLOAT4:
-			case BVM_MATRIX44:
-				/* pass by reference */
-				return true;
-				
-			case BVM_STRING:
-			case BVM_RNAPOINTER:
-			case BVM_MESH:
-			case BVM_DUPLIS:
-				/* TODO */
-				break;
-		}
+		return false;
 	}
-	
-	return false;
 }
 
 llvm::Constant *LLVMSimpleCompilerImpl::create_node_value_constant(const NodeValue *node_value)




More information about the Bf-blender-cvs mailing list