From patchwork Mon Jul 30 19:38:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 10373 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CC78523F61 for ; Mon, 30 Jul 2012 19:38:57 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 7C02FA18B81 for ; Mon, 30 Jul 2012 19:38:57 +0000 (UTC) Received: by ghbz12 with SMTP id z12so5146143ghb.11 for ; Mon, 30 Jul 2012 12:38:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:in-reply-to:references:organization :x-mailer:mime-version:content-type:x-originalarrivaltime :x-gm-message-state; bh=W8RmHR4iDe4F7aS3o7+ouvXEzwXiIPQpnsWw9IyIzic=; b=N1qDvVv4wZpk1ABVvF+QJ/jntZW0dFWiyTdBElCTgQfRbp6kdRU527cctzN+PPx16l MGiVZO5y78lr4lNTn6zMxf495gPxMbtrlrTt0hAQuTj3oixJstV9HGAtuepNrcTpBkRx WdQYlC0wQHBFz4+6as0BR3shdDLh9UNsN2+FBGIzGOOpfsy6X9o9MnjrJaDdMHLwefqd iXqcIfIWAANSr+XZuYyuleMxhFPnj3s+yAvJEWcB8+f2RlX0jle3T3mdHn1I0GaMuETU 83cvc1jkf1jWULhiPrmXOhoM7fUhKV3Y+lQ5lYyobHUWtlYaMv+/0O44HMc7welc/BZe Epuw== Received: by 10.50.197.232 with SMTP id ix8mr92473igc.73.1343677136310; Mon, 30 Jul 2012 12:38:56 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.87.40 with SMTP id u8csp106151igz; Mon, 30 Jul 2012 12:38:55 -0700 (PDT) Received: by 10.68.129.38 with SMTP id nt6mr12910797pbb.76.1343677132030; Mon, 30 Jul 2012 12:38:52 -0700 (PDT) Received: from relay1.mentorg.com (relay1.mentorg.com. [192.94.38.131]) by mx.google.com with ESMTPS id ur10si12360035pbc.308.2012.07.30.12.38.50 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Jul 2012 12:38:51 -0700 (PDT) Received-SPF: neutral (google.com: 192.94.38.131 is neither permitted nor denied by best guess record for domain of Julian_Brown@mentor.com) client-ip=192.94.38.131; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.94.38.131 is neither permitted nor denied by best guess record for domain of Julian_Brown@mentor.com) smtp.mail=Julian_Brown@mentor.com Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Svvnk-0002jN-IN from Julian_Brown@mentor.com ; Mon, 30 Jul 2012 12:38:48 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 30 Jul 2012 12:38:48 -0700 Received: from octopus (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Mon, 30 Jul 2012 20:38:46 +0100 Date: Mon, 30 Jul 2012 20:38:38 +0100 From: Julian Brown To: Ramana Radhakrishnan CC: , Patch Tracking , Richard Earnshaw Subject: Re: [Patch ARM 4/6] Improve Neon intrinsics testsuite. Message-ID: <20120730203838.09d6749a@octopus> In-Reply-To: References: Organization: Mentor Graphics X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-OriginalArrivalTime: 30 Jul 2012 19:38:48.0379 (UTC) FILETIME=[F08AE8B0:01CD6E8A] X-Gm-Message-State: ALoCoQlBvKQECday2saBKi0rs8Lzr2iWs+y5NRXACNJZreYM5WEpZ8992OKFDd9BH/7uW2T5eD08 On Mon, 30 Jul 2012 12:51:47 +0100 Ramana Radhakrishnan wrote: > This patch converts the testsuite generator to actually produce > something more sensible than the current set of tests. It changes > these to generate the following form for a test instead of the > previous set of tests. > > It's careful to use the hard-fp variant so that we actually > produce an instruction (atleast a move of the appropriate form) and > uses a dummy floating point parameter to ensure this. This ensures > that most tests are alright. This does increase test times quite a bit > and I'm considering a follow-up to the build system that tries to do > some of these tests in parallel. > > It's been useful and instructive so far and has found a few issues > in the compiler and probably been the twistiest passage in this maze > of twisty little passages. The Ocaml bits mostly look fine to me, modulo a few formatting nits (redundant brackets, begin/end pairs) fixed in the attached version, which works the same as before AFAICT. I also factored out the kind-of-duplicate print_args functions into a generalised version -- not amazingly useful, but mildly more concise. HTH, Julian Index: neon-testgen.ml =================================================================== --- neon-testgen.ml (revision 189983) +++ neon-testgen.ml (working copy) @@ -1,5 +1,6 @@ (* Auto-generate ARM Neon intrinsics tests. - Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software + Foundation, Inc. Contributed by CodeSourcery. This file is part of GCC. @@ -51,80 +52,84 @@ Printf.fprintf chan "/* This file was autogenerated by neon-testgen. */\n\n"; Printf.fprintf chan "/* { dg-do assemble } */\n"; Printf.fprintf chan "/* { dg-require-effective-target arm_neon_ok } */\n"; - Printf.fprintf chan "/* { dg-options \"-save-temps -O0\" } */\n"; + Printf.fprintf chan "/* { dg-options \"-save-temps\" } */\n"; Printf.fprintf chan "/* { dg-add-options arm_neon } */\n"; - Printf.fprintf chan "\n#include \"arm_neon.h\"\n\n"; - Printf.fprintf chan "void test_%s (void)\n{\n" test_name + Printf.fprintf chan "\n#include \"arm_neon.h\"\n\n" -(* Emit declarations of local variables that are going to be passed +(* Convert a list ORIGLIST to a string, calling MAP with a + monotonically-increasing index and the element for each element of that + list, and separating entries with SEP. *) + +let idx_concat sep map origlist = + let buf = Buffer.create 30 in + let rec scan idx = function + [] -> + Buffer.contents buf + | [item] -> + Buffer.add_string buf (map idx item); + Buffer.contents buf + | item::items -> + Buffer.add_string buf (map idx item); + Buffer.add_string buf sep; + scan (succ idx) items in + scan 0 origlist + +(* Emit function with parameters and local variables that are going to be passed to an intrinsic, together with one to take a returned value if needed. *) -let emit_automatics chan c_types features = - let emit () = - ignore ( - List.fold_left (fun arg_number -> fun (flags, ty) -> - let pointer_bit = - if List.mem Pointer flags then "*" else "" - in - (* Const arguments to builtins are directly - written in as constants. *) - if not (List.mem Const flags) then - Printf.fprintf chan " %s %sarg%d_%s;\n" - ty pointer_bit arg_number ty; - arg_number + 1) - 0 (List.tl c_types)) +let emit_test_prologue chan c_types features test_name const_valuator = + let print_arg arg_number (flags, ty) = + (* If the argument is of const type, then directly write in the + constant now. *) + let pointer_bit = if List.mem Pointer flags then "*" else "" in + Printf.sprintf "%s %s arg%d_%s" ty pointer_bit arg_number ty in - match c_types with - (_, return_ty) :: tys -> - if return_ty <> "void" then begin - (* The intrinsic returns a value. We need to do explict register - allocation for vget_low tests or they fail because of copy - elimination. *) - ((if List.mem Fixed_vector_reg features then - Printf.fprintf chan " register %s out_%s asm (\"d18\");\n" - return_ty return_ty - else if List.mem Fixed_core_reg features then - Printf.fprintf chan " register %s out_%s asm (\"r0\");\n" - return_ty return_ty - else - Printf.fprintf chan " %s out_%s;\n" return_ty return_ty); - emit ()) - end else - (* The intrinsic does not return a value. *) - emit () - | _ -> assert false + match c_types with + (_, return_ty) :: tys -> + Printf.fprintf chan + "%s __attribute__ ((pcs (\"aapcs-vfp\")))\ntest_%s (float dummy_param, " + return_ty test_name; + output_string chan (idx_concat ",\n\t" print_arg (List.tl c_types)); + Printf.fprintf chan ")\n{\n"; + if return_ty <> "void" then begin + (* The intrinsic returns a value. We need to do explict register + allocation for vget_low tests or they fail because of copy + elimination. *) + if List.mem Fixed_vector_reg features then + Printf.fprintf chan " register %s out_%s asm (\"d18\");\n" + return_ty return_ty + else if List.mem Fixed_core_reg features then + Printf.fprintf chan " register %s out_%s asm (\"r0\");\n" + return_ty return_ty + else + Printf.fprintf chan " %s out_%s;\n" return_ty return_ty + end + | _ -> assert false (* Emit code to call an intrinsic. *) let emit_call chan const_valuator c_types name elt_ty = - (if snd (List.hd c_types) <> "void" then - Printf.fprintf chan " out_%s = " (snd (List.hd c_types)) - else - Printf.fprintf chan " "); + if snd (List.hd c_types) <> "void" then + Printf.fprintf chan " out_%s = " (snd (List.hd c_types)) + else + Printf.fprintf chan " "; Printf.fprintf chan "%s_%s (" (intrinsic_name name) (string_of_elt elt_ty); - let print_arg chan arg_number (flags, ty) = + let print_arg arg_number (flags, ty) = (* If the argument is of const type, then directly write in the constant now. *) if List.mem Const flags then match const_valuator with None -> if List.mem Pointer flags then - Printf.fprintf chan "0" + Printf.sprintf "arg%d_%s " arg_number ty else - Printf.fprintf chan "1" - | Some f -> Printf.fprintf chan "%s" (string_of_int (f arg_number)) + Printf.sprintf "1 " + | Some f -> Printf.sprintf "%s " (string_of_int (f arg_number)) else - Printf.fprintf chan "arg%d_%s" arg_number ty + Printf.sprintf "arg%d_%s" arg_number ty in - let rec print_args arg_number tys = - match tys with - [] -> () - | [ty] -> print_arg chan arg_number ty - | ty::tys -> - print_arg chan arg_number ty; - Printf.fprintf chan ", "; - print_args (arg_number + 1) tys - in - print_args 0 (List.tl c_types); - Printf.fprintf chan ");\n" + output_string chan (idx_concat ", " print_arg (List.tl c_types)); + Printf.fprintf chan ");\n"; + if snd (List.hd c_types) <> "void" then + Printf.fprintf chan " return out_%s;\n" (snd (List.hd c_types)) (* Emit epilogue code to a test source file. *) let emit_epilogue chan features regexps = @@ -265,12 +270,12 @@ in (* Emit file and function prologues. *) emit_prologue chan test_name; - (* Emit local variable declarations. *) - emit_automatics chan c_types features; + (* Emit prologue for the test function. *) + emit_test_prologue chan c_types features test_name const_valuator; Printf.fprintf chan "\n"; (* Emit the call to the intrinsic. *) emit_call chan const_valuator c_types name elt_ty; - (* Emit the function epilogue and the DejaGNU scan-assembler directives. *) + (* Emit the DejaGNU scan-assembler directives. *) emit_epilogue chan features regexps; (* Close the test file. *) close_out chan