{"action":"created","issue":{"url":"https://api.github.com/repos/ldc-developers/ldc/issues/1434","repository_url":"https://api.github.com/repos/ldc-developers/ldc","labels_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1434/labels{/name}","comments_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1434/comments","events_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1434/events","html_url":"https://github.com/ldc-developers/ldc/pull/1434","id":148675050,"number":1434,"title":"[WIP] Add LDC-specific traits for CTFE information about the target machine.","user":{"login":"JohanEngelen","id":10983051,"avatar_url":"https://avatars.githubusercontent.com/u/10983051?v=3","gravatar_id":"","url":"https://api.github.com/users/JohanEngelen","html_url":"https://github.com/JohanEngelen","followers_url":"https://api.github.com/users/JohanEngelen/followers","following_url":"https://api.github.com/users/JohanEngelen/following{/other_user}","gists_url":"https://api.github.com/users/JohanEngelen/gists{/gist_id}","starred_url":"https://api.github.com/users/JohanEngelen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohanEngelen/subscriptions","organizations_url":"https://api.github.com/users/JohanEngelen/orgs","repos_url":"https://api.github.com/users/JohanEngelen/repos","events_url":"https://api.github.com/users/JohanEngelen/events{/privacy}","received_events_url":"https://api.github.com/users/JohanEngelen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2016-04-15T14:26:36Z","updated_at":"2016-04-23T10:45:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ldc-developers/ldc/pulls/1434","html_url":"https://github.com/ldc-developers/ldc/pull/1434","diff_url":"https://github.com/ldc-developers/ldc/pull/1434.diff","patch_url":"https://github.com/ldc-developers/ldc/pull/1434.patch"},"body":"This adds the following LDC-specific traits:\r\n```D\r\n__traits(targetCPU) == \"broadwell\"\r\n__traits(targetFeatures) == Tuple(\"sse\", \"sse2\", ...)\r\n__traits(targetHasFeature, \"sse2\") == bool\r\n```\r\n\r\nExample usage:\r\n```D\r\nimport std.stdio;\r\nvoid main() {\r\n  writeln(\"CPU = \", __traits(targetCPU));\r\n  writeln(\"Features = \", [__traits(targetFeatures)]);\r\n  writeln(\"Has 'sse3' = \", __traits(targetHasFeature, \"sse3\"));\r\n  writeln(\"Has 'sse4' = \", __traits(targetHasFeature, \"sse4\"));\r\n  writeln(\"Has 'sse4.1' = \", __traits(targetHasFeature, \"sse4.1\"));\r\n}\r\n```\r\nOutputs on my machine:\r\n```\r\n❯ ../bin/ldc2 -wi -mcpu=native -run ../../tests/codegen/target_traits.d\r\nCPU = haswell\r\nFeatures = [\"cx16\", \"xsave\", \"bmi2\", \"fsgsbase\", \"avx\", \"popcnt\", \"fma\", \"bmi\", \"aes\", \"rdrnd\", \"sse4.1\", \"sse4.2\", \"avx2\", \"sse\", \"lzcnt\", \"pclmul\", \"f16c\", \"ssse3\", \"mmx\", \"cmov\", \"movbe\", \"xsaveopt\", \"sse2\", \"sse3\"]\r\nHas 'sse3' = true\r\nHas 'sse4' = false\r\nHas 'sse4.1' = true\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ldc-developers/ldc/issues/comments/213718086","html_url":"https://github.com/ldc-developers/ldc/pull/1434#issuecomment-213718086","issue_url":"https://api.github.com/repos/ldc-developers/ldc/issues/1434","id":213718086,"user":{"login":"JohanEngelen","id":10983051,"avatar_url":"https://avatars.githubusercontent.com/u/10983051?v=3","gravatar_id":"","url":"https://api.github.com/users/JohanEngelen","html_url":"https://github.com/JohanEngelen","followers_url":"https://api.github.com/users/JohanEngelen/followers","following_url":"https://api.github.com/users/JohanEngelen/following{/other_user}","gists_url":"https://api.github.com/users/JohanEngelen/gists{/gist_id}","starred_url":"https://api.github.com/users/JohanEngelen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohanEngelen/subscriptions","organizations_url":"https://api.github.com/users/JohanEngelen/orgs","repos_url":"https://api.github.com/users/JohanEngelen/repos","events_url":"https://api.github.com/users/JohanEngelen/events{/privacy}","received_events_url":"https://api.github.com/users/JohanEngelen/received_events","type":"User","site_admin":false},"created_at":"2016-04-23T10:45:56Z","updated_at":"2016-04-23T10:45:56Z","body":"I removed `__traits(targetFeatures)` as this list is not obtainable without hacking LLVM. `__traits(targetHasFeature)` is more useful and this can be obtained from LLVM with some effort.\r\nUpdated the PR."}}