Merge pull request #1 from r-potter/hsail-3.6

Fix invalid data layout for BRIGAsmPrinter on 64-bit HSAIL.
Update libHSAIL
Reapply "Quick fix for OS X build" to new libHSAIL
Updates for libHSAIL changes
Fix build error
Re-disable error check disabled by 67242fea
Remove leftover directory from OpenCL build
P4 to Git Change 1058773 by avolkov@avolkov_spb_stg_ocl on 2014/07/24 07:10:23

	EPR #402924 - [CQE OCL][ 2.0][ISV][G]Few subtest of 64&32bit CompuBenchCL app having Video Corruption. Part 1 (src)

	[Problem Description]
	Video Corruption Observed in few subtests as below in HSAIL path:

	CompuBenchCL 1.5 (64bit App)
	Face Detection(mpixel/sec)	 Video Corruption
	TV-L1 Optical Flow(mpixel/sec)	 Video Corruption
	T-Rex(frames/sec)	  Video Corruption
	Video Composition(FPS)	  Video Corruption

	[Root Cause]
	Problem in tests Face Detection and Video Composition in optimization div operation. Divide on 64 bit value have invalid HSAIL sequence.
	This fix not solved other corruption. It will be fixed in other CL`s.

	[Solution Description]
	Need remove mulhi_u32 rule from llvm TD rules. This rures was incorrect

	[Reviewed By]
	Stanislav Mekhanoshin

	[Review Link]
	In email thread "OCL2.0 bug 10089"

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILFusion.td#9 edit
P4 to Git Change 1060425 by yaxunl@yaxunl_stg_win50 on 2014/07/29 11:37:27

	ECR #333753 - Bug 10051 [CQE OCL 2.0][ISV][G] Blender application is crashing in HSAIL path.

	DAGCombiner transform a>0?a:-a to llvm fabs intrinsic. It needs to be transformed to HSAIL fabs intrinsic before it can be instruction selected. However HSAIL fabs is defined without IntrNoMem property which results in chain in its SDNode, which causes LLVM fabs intrinsic cannot be translated to HSAIL intrinsic since LLVM fabs is defined with IntrNoMem property therefore has no chain. Also in the library __hsail_abs_f[32|64] should be defined with __attribute__((const)) instead of pure since only __attribute__((const)) results in InstNoMem builtin therefore no chain.

	This CL modified  __hsail_abs_f[32|64] with __attribute__((const)) and added IntrNoMem property to HSAIL fabs intrinsic so that its SDNode has no chain child node. Also it defines pattern to transform llvm fabs to HSAIL fabs.

	Ideally all HSAIL intrinsics which does not read/write mem should have IntrNoMem property, but that is better be done with a separate bug to avoid regressions.

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILArithmetic.td#10 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILInstrFormats.td#10 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILIntrinsics.td#32 edit
... //depot/stg/opencl/drivers/opencl/library/hsa/hsail/src/misc/amdil-to-hsail.cl#6 edit
P4 to Git Change 1061423 by nhaustov@nhaustov_hsa on 2014/07/31 04:34:11

	ECR #010005 - Update to HSAIL PRM 1.0p. [ opencl changes ]

	Changes by Oleg Semenov, Dmitry Preobrazhensky, Valery Pykhtin.

	Testing: full CQE on multiple ASICs, smoke, finalizer_features, regression, OCL conformance 1.2 (offline).
P4 to Git Change 1061458 by smekhano@rampitec-HSA on 2014/07/31 08:25:37

	ECR #333753 - HSA HLC: call support and argument ld/st improvements to build Blender

	Handling of struct, array and composite call arguments. This covers the case when a struct is passed not flattened.
	Moved some utility functions into HSAILUtilities from BRIGAsmPringer.
	Fixed HSAIL Move Kernarg optimization to keep track of argscope (and touch nothing in there).
	Fixed at least some argument alignment handling:
	         - more use of DataLayout instead of calculations
	         - distinction between ABI and preferred alignment contexts
	         - some trivial bug fixes).
	Arg decl instruction now contains alignment info not really deducible in BRIGAsmPrinter.

	Effectively this allows us to compile Blender with call support.

	Some additional improvements:
	- Added TBAA for argument loads and stores and supported their vectorization
	- Fixed HSAIL memory optimizations in various ways:
	  1) Out of order loads and stores can be vectorized now. Before it was calculating incorrect offsets.
	  2) Correctly handled overflow in memory operands distance calculation.
	  3) Proper alignment and other attributes are recorded from base address to the vector load or store.
	  4) Move kernargs support vector loads.
	- Max alignment uses define Brig::BRIG_ALIGNMENT_MAX instead of hardcoded 128.
	- ld_kernarg intrinsic lowering tries to match immediate address against kernel argument map to use argument symbol when possible.
	- DAG2DAG implementation of ld_kernarg uses the same getArgLoadOrStore() infrastructure as general lowering,
	         so it has all the same attributes as a regular arg load whenever possible. This also simplifies code somewhat.
	- Removed alignment operand from load and store. It is present in the memory operand which does exist for any load or store now.
	  As a consequence removed pass to copy alignment info from mem ops to explicit operands.

	Testing: smoke, smoke_clang, precheckin, ocl_features -M call, Blender offline compilation, vec_ldst, llc_opt -M width
	Reviewed by Oleg Semenov

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/BRIGAsmPrinter.cpp#64 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelDAGToDAG.cpp#22 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelLowering.cpp#53 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelLowering.h#16 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILInstrInfo.cpp#16 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILLoadStore.td#33 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILMachineFunctionInfo.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILMachineFunctionInfo.h#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILOperands.td#6 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILOptimizeMemoryOps.cpp#15 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILParamManager.cpp#6 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILParamManager.h#5 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILTargetMachine.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILUtilityFunctions.cpp#28 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILUtilityFunctions.h#19 edit
P4 to Git Change 1061523 by smekhano@rampitec-HSA on 2014/07/31 11:17:26

	ECR #333753 - HSA HLC: fix for symbol declared as static const in a global scope
	Currently this results in a private address space declaration which cannot have initializer and thus BRIG cannot be produced.
	This change fixes the issue.
	Additionally global addresspace variables in a global scope are promoted to readonly segment if constant.

	Testing: smoke, smoke_clang, precheckin
	Reviewed by Valery Pykhtin

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/BRIGAsmPrinter.cpp#65 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/BRIGAsmPrinter.h#28 edit
P4 to Git Change 1061548 by shivara@shivaram_llvmmerge_dt on 2014/07/31 11:49:30

	ECR #333753 - Fixes to conformance test get_kernel_arg_info.

	HSAILParseMetadata function is modified to accept the type qualifiers in single meta data node (space separated).
	HSAILKernelManager is modified to handle Q_CONST type qualifier.
	AMDParser.y is modified to accept spaces in type names.

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/AMDIL/MDParser/AMDILMDParser.output#23 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/AMDIL/MDParser/AMDILMDParser.tab.cpp#37 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/AMDIL/MDParser/AMDILMDParser.y#48 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILKernelManager.cpp#22 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILParseMetadata.cpp#7 edit
P4 to Git Change 1061983 by smekhano@rampitec-HSA on 2014/08/01 06:19:15

	ECR #333753 - HSA HLC: generate kernargbaseptr instruction for immediate references with unknown base
	Fix for bug 9732.

	Testing: smoke, smoke_clang, precheckin, ocl_features -M call
	This introduces 3 new failures in ocl_features -M call due to "Error: !"BRIG_OPCODE_KERNARGBASEPTR not supported yet" at .../HSAILSpecial.cpp:643". See bug 10168.

	Reviewed by Nikolay Haustov

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelLowering.cpp#54 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILSpecial.td#13 edit
P4 to Git Change 1062030 by smekhano@rampitec-HSA on 2014/08/01 10:29:24

	ECR #333753 - HSA HLC: remove some obviously dead code from HSAIL BE
	Testing: smoke, smoke_clang, precheckin
	Reviewed by Nikolay Haustov

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/Android.mk#17 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/BRIGAsmPrinter.cpp#66 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/BRIGAsmPrinter.h#29 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/CMakeLists.txt#7 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILAsmBackend.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILAsmBackend.h#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILELFTargetObjectFile.cpp#2 delete
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILELFTargetObjectFile.h#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILELFWriterInfo.cpp#4 delete
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILFastISel.cpp#2 delete
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILFixupKinds.h#2 delete
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILFrameLowering.cpp#4 delete
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILFrameLowering.h#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelDAGToDAG.cpp#23 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelLowering.cpp#55 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelLowering.h#17 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILMCCodeEmitter.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILMCCodeEmitter.h#3 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILMergeLoadStores.cpp#2 delete
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILRegisterInfo.cpp#9 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILRegisterInfo.h#6 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILSelectionDAGInfo.cpp#2 delete
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILSelectionDAGInfo.h#2 delete
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILSubtarget.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILSubtarget.h#6 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILTargetMachine.h#9 edit
P4 to Git Change 1063385 by smekhano@stas-spb-hlc-kv2-hsa on 2014/08/06 09:56:19

	EPR #403852 - HSA HLC: fix for vec3 global allocation
	Fixes conformance 2.0 `test_basic.exe progvar_prog_scope_uninit progvar_prog_scope_init' (bug 10200).

	Testing: smoke, smoke_clang, precheckin, ocl_features -M call
	Reviewed by Valery Pykhtin

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/BRIGAsmPrinter.cpp#68 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILUtilityFunctions.cpp#29 edit
P4 to Git Change 1063869 by smekhano@stas-spb-hlc-kv2-hsa on 2014/08/07 09:03:27

	ECR #333753 - HSA HLC: fixed offset calculation in SelectAddr()
	The issue occurs quite rare when offset is being added two contants, e.g. address = base + const1 + const2.

	Testing: smoke, precheckin
	Reviewed by Oleg Semenov

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelDAGToDAG.cpp#24 edit
P4 to Git Change 1064070 by smekhano@stas-solstice-HSA on 2014/08/07 16:38:52

	ECR #333753 - HSA HLC: Optimize i8|i16 zext load into i64
	This change optimizes pattern (and (i64 load sext i8|i16), 0xff|0xffff) by removing "and" and changing sext to zext.
	The problem first erected with HSAIL 0.98 which has prohibited direct extending loads from sub-dword to i64.

	Testing: smoke, smoke_clang, precheckin, vec_ldst
	Reviewed by Oleg Semenov

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelLowering.cpp#56 edit
P4 to Git Change 1064883 by yaxunl@yaxunl_stg_win50 on 2014/08/11 11:21:54

	EPR #401388 - [CQE OCL][LNX][ISV][G] One specific Bullet 3.x GPU test failed.

	The failure was due to bug in AMDIL structurizer. When there are multiple exiting blocks in an inner loop, the first exiting block needs to set value for block end reg since the initialization only happens at the outmost loop.

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/AMDIL/AMDILCFGStructurizer.cpp#192 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/test/CodeGen/AMDIL/cfg-structurizer-loop-break.ll#1 add
P4 to Git Change 1065496 by smekhano@stas-spb-hlc-kv2-hsa on 2014/08/12 15:24:03

	ECR #333753 - HSA HLC: add required attributes to atomics after lowering
	Things which were missing:
	- memory operand (lost together with volatile status)
	- mayLoad and mayStore

	Testing: smoke, smoke_clang, precheckin, llc_opt -M width
	Reviewed by Oleg Semenov

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILAtomics.td#11 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/HSAIL/HSAILISelDAGToDAG.cpp#25 edit