[Beignet] [PATCH] Implement the %p in the printf
Zhigang Gong
zhigang.gong at linux.intel.com
Tue Jun 24 17:13:11 PDT 2014
LGTM, pushed, thanks.
On Tue, Jun 24, 2014 at 11:33:20PM +0800, junyan.he at inbox.com wrote:
> From: Junyan He <junyan.he at linux.intel.com>
>
> Signed-off-by: Junyan He <junyan.he at linux.intel.com>
> ---
> backend/src/ir/printf.cpp | 3 +++
> backend/src/ir/printf.hpp | 3 ++-
> backend/src/llvm/llvm_printf_parser.cpp | 21 +++++++++++++++++----
> 3 files changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/backend/src/ir/printf.cpp b/backend/src/ir/printf.cpp
> index 68b2ce4..9d60402 100644
> --- a/backend/src/ir/printf.cpp
> +++ b/backend/src/ir/printf.cpp
> @@ -193,6 +193,9 @@ namespace gbe
> case PRINTF_CONVERSION_a:
> PRINT_SOMETHING(float, a);
> break;
> + case PRINTF_CONVERSION_P:
> + PRINT_SOMETHING(int, p);
> + break;
>
> case PRINTF_CONVERSION_S:
> pf_str = pf_str + "s";
> diff --git a/backend/src/ir/printf.hpp b/backend/src/ir/printf.hpp
> index 680b8e6..1aef767 100644
> --- a/backend/src/ir/printf.hpp
> +++ b/backend/src/ir/printf.hpp
> @@ -196,7 +196,8 @@ namespace gbe
> case PRINTF_CONVERSION_U:
> case PRINTF_CONVERSION_X:
> case PRINTF_CONVERSION_x:
> - /* Char will be aligned to sizeof(int) here. */
> + case PRINTF_CONVERSION_P:
> + /* Char will be aligned to sizeof(int) here. */
> case PRINTF_CONVERSION_C:
> return (uint32_t)(sizeof(int) * vec_num);
> case PRINTF_CONVERSION_E:
> diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp
> index ff8e259..74b57ab 100644
> --- a/backend/src/llvm/llvm_printf_parser.cpp
> +++ b/backend/src/llvm/llvm_printf_parser.cpp
> @@ -228,7 +228,7 @@ namespace gbe
> CONVERSION_SPEC_AND_RET('s', S)
> CONVERSION_SPEC_AND_RET('p', P)
>
> - // %% has been handled
> + // %% has been handled
>
> default:
> return -1;
> @@ -334,7 +334,8 @@ error:
> static map<CallInst*, PrintfSet::PrintfFmt*> printfs;
> int printf_num;
>
> - PrintfParser(void) : FunctionPass(ID) {
> + PrintfParser(void) : FunctionPass(ID)
> + {
> module = NULL;
> builder = NULL;
> intTy = NULL;
> @@ -345,7 +346,8 @@ error:
> printf_num = 0;
> }
>
> - ~PrintfParser(void) {
> + ~PrintfParser(void)
> + {
> for (auto &s : printfs) {
> delete s.second;
> s.second = NULL;
> @@ -357,7 +359,8 @@ error:
> bool parseOnePrintfInstruction(CallInst *& call);
> bool generateOneParameterInst(PrintfSlot& slot, Value*& arg, Type*& dst_type, int& sizeof_size);
>
> - virtual const char *getPassName() const {
> + virtual const char *getPassName() const
> + {
> return "Printf Parser";
> }
>
> @@ -744,8 +747,18 @@ error:
> slot.state->str = fmt_arg->getAsCString();
> return true;
> }
> + case PRINTF_CONVERSION_P: {
> + arg = builder->CreatePtrToInt(arg, Type::getInt32Ty(module->getContext()));
> + dst_type = arg->getType()->getPointerTo(1);
> + sizeof_size = sizeof(int);
> + return true;
> + }
> + default:
> + return false;
> }
>
> + break;
> +
> case Type::VectorTyID: {
> Type* vect_type = arg->getType();
> Type* elt_type = vect_type->getVectorElementType();
> --
> 1.7.9.5
>
>
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list