From 9ee09b9b2cb498219bd8012bed69ecf63fce63a4 Mon Sep 17 00:00:00 2001 From: xleroy Date: Wed, 27 Aug 2014 09:51:01 +0000 Subject: Rename __builtin_cntlz to __builtin_clz. IA32: add __builtin_clz, __builtin_ctz. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2619 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- ia32/CBuiltins.ml | 4 ++++ ia32/PrintAsm.ml | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'ia32') diff --git a/ia32/CBuiltins.ml b/ia32/CBuiltins.ml index 6046126..765f5b1 100644 --- a/ia32/CBuiltins.ml +++ b/ia32/CBuiltins.ml @@ -29,6 +29,10 @@ let builtins = { (TInt(IUInt, []), [TInt(IUInt, [])], false); "__builtin_bswap16", (TInt(IUShort, []), [TInt(IUShort, [])], false); + "__builtin_clz", + (TInt(IUInt, []), [TInt(IUInt, [])], false); + "__builtin_ctz", + (TInt(IUInt, []), [TInt(IUInt, [])], false); (* Float arithmetic *) "__builtin_fsqrt", (TFloat(FDouble, []), [TFloat(FDouble, [])], false); diff --git a/ia32/PrintAsm.ml b/ia32/PrintAsm.ml index 56e837d..8828faa 100644 --- a/ia32/PrintAsm.ml +++ b/ia32/PrintAsm.ml @@ -448,6 +448,11 @@ let print_builtin_inline oc name args res = if a1 <> res then fprintf oc " movl %a, %a\n" ireg a1 ireg res; fprintf oc " rolw $8, %a\n" ireg16 res + | "__builtin_clz", [IR a1], [IR res] -> + fprintf oc " bsrl %a, %a\n" ireg a1 ireg res; + fprintf oc " xorl $31, %a\n" ireg res + | "__builtin_ctz", [IR a1], [IR res] -> + fprintf oc " bsfl %a, %a\n" ireg a1 ireg res (* Float arithmetic *) | "__builtin_fabs", [FR a1], [FR res] -> need_masks := true; -- cgit v1.2.3