[clang] partial translation of vector instructions

Reviewed By: jvillard

Differential Revision: D5701932

fbshipit-source-id: 8bdef6d
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent b4c0ddcff3
commit de9d8f45ff

@ -57,6 +57,10 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron
| CTrans_utils.TemplatedCodeException _
-> L.internal_error "Fatal error: frontend doesn't support translation of templated code@\n" ;
handle_translation_failure ()
| CTrans_utils.UnsupportedStatementException stmt when Config.keep_going
-> L.internal_error "Unimplemented: translation for statement %s"
(Clang_ast_proj.get_stmt_kind_string stmt) ;
handle_translation_failure ()
| Assert_failure (file, line, column) when Config.keep_going
-> L.internal_error "Fatal error: exception Assert_failure(%s, %d, %d)@\n%!" file line column ;
handle_translation_failure ()

@ -2903,6 +2903,9 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
let typ = CType_decl.get_type_from_expr_info expr_info tenv in
{empty_res_trans with exps= [(CTrans_utils.undefined_expression (), typ)]}
(* no-op translated for unsupported instructions that will at least translate subexpressions *)
and skip_unimplemented trans_state stmts = instructions trans_state stmts
(* Translates a clang instruction into SIL instructions. It takes a *)
(* a trans_state containing current info on the translation and it returns *)
(* a result_state.*)
@ -3120,6 +3123,11 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
-> trans_into_undefined_expr trans_state expr_info
| ArrayInitIndexExpr _ | ArrayInitLoopExpr _
-> no_op_trans trans_state.succ_nodes
(* vector instructions for OpenCL etc. we basically ignore these for now; just translate the
sub-expressions *)
| ExtVectorElementExpr (_, stmts, _)
| ShuffleVectorExpr (_, stmts, _)
-> skip_unimplemented trans_state stmts
(* Infer somehow ended up in templated non instantiated code - right now
it's not supported and failure in those cases is expected. *)
| SubstNonTypeTemplateParmExpr _
@ -3127,10 +3135,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| CXXDependentScopeMemberExpr _
-> raise (CTrans_utils.TemplatedCodeException instr)
| s
-> L.(debug Capture Medium)
"@\n!!!!WARNING: found statement %s. @\nACTION REQUIRED: Translation need to be defined. Statement ignored.... @\n"
(Clang_ast_proj.get_stmt_kind_string s) ;
assert false
-> raise (CTrans_utils.UnsupportedStatementException s)
(* Function similar to instruction function, but it takes C++ constructor initializer as
an input parameter. *)

@ -16,6 +16,8 @@ module L = Logging
exception TemplatedCodeException of Clang_ast_t.stmt
exception UnsupportedStatementException of Clang_ast_t.stmt
(* Extract the element of a singleton list. If the list is not a singleton *)
(* It stops the computation giving a warning. We use this because we *)
(* assume in many places that a list is just a singleton. We use the *)

@ -38,6 +38,8 @@ type trans_result =
exception TemplatedCodeException of Clang_ast_t.stmt
exception UnsupportedStatementException of Clang_ast_t.stmt
val empty_res_trans : trans_result
val undefined_expression : unit -> Exp.t

@ -0,0 +1,12 @@
/*
1;95;0c * Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
typedef __attribute__((ext_vector_type(2))) float vec_float2;
vec_float2 simple(vec_float2 vec) { return vec.xy; }

@ -0,0 +1,14 @@
/* @generated */
digraph iCFG {
"simple#_Z6simpleDv2_f.e9c9c4d600ba08c47099d8822b175fec_1" [label="1: Start simple\nFormals: vec:void\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled]
"simple#_Z6simpleDv2_f.e9c9c4d600ba08c47099d8822b175fec_1" -> "simple#_Z6simpleDv2_f.e9c9c4d600ba08c47099d8822b175fec_3" ;
"simple#_Z6simpleDv2_f.e9c9c4d600ba08c47099d8822b175fec_2" [label="2: Exit simple \n " color=yellow style=filled]
"simple#_Z6simpleDv2_f.e9c9c4d600ba08c47099d8822b175fec_3" [label="3: Return Stmt \n n$0=*&vec:void [line 12]\n *&return:void=n$0 [line 12]\n " shape="box"]
"simple#_Z6simpleDv2_f.e9c9c4d600ba08c47099d8822b175fec_3" -> "simple#_Z6simpleDv2_f.e9c9c4d600ba08c47099d8822b175fec_2" ;
}
Loading…
Cancel
Save